ZQuest Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2024-05-08 03:28:19
Exec Total Coverage
Lines: 8936 12564 71.1%
Functions: 97 129 75.2%
Branches: 6270 10720 58.5%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/version.h"
4 #include "base/zapp.h"
5 #include "base/qrs.h"
6 #include "base/cpool.h"
7 #include "base/autocombo.h"
8 #include "base/packfile.h"
9 #include "base/dmap.h"
10 #include "base/combo.h"
11 #include "base/msgstr.h"
12 #include <filesystem>
13 #include <memory>
14 #include <optional>
15 #include <stdio.h>
16 #include <cstring>
17 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "zc/replay.h"
36 #include "zc/zasm_utils.h"
37 #include "zc/zc_custom.h"
38 #include "sfx.h"
39 #include "md5.h"
40 #include "zinfo.h"
41 #include "zc/ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 #include "base/misctypes.h"
45 #include "base/initdata.h"
46
47 //FFScript FFCore;
48 extern FFScript FFCore;
49 extern ZModule zcm;
50 extern zcmodule moduledata;
51 extern uint8_t __isZQuest;
52 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
53 extern particle_list particles;
54 extern void setZScriptVersion(int32_t s_version);
55 //FFSCript FFEngine;
56
57 static bool read_ext_zinfo = false, read_zinfo = false;
58 static bool loadquest_report = false;
59 static char const* loading_qst_name = NULL;
60 static byte loading_qst_num = 0;
61 static byte subscr_mode = ssdtMAX;
62 dword loading_tileset_flags = 0;
63
64 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
65 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
66
67 #ifdef _MSC_VER
68 #define strncasecmp _strnicmp
69 #endif
70
71 #ifndef _AL_MALLOC
72 #define _AL_MALLOC(a) _al_malloc(a)
73 #define _AL_FREE(a) _al_free(a)
74 #endif
75
76 using std::string;
77 using std::pair;
78
79 // extern bool debug;
80 extern int32_t hero_animation_speed; //lower is faster animation
81 extern byte *colordata;
82 //extern byte *tilebuf;
83 extern tiledata *newtilebuf;
84 extern byte *trashbuf;
85 extern itemdata *itemsbuf;
86 extern wpndata *wpnsbuf;
87 extern comboclass *combo_class_buf;
88 extern guydata *guysbuf;
89 extern ZCHEATS zcheats;
90 extern char palnames[MAXLEVELS][17];
91 extern char *byte_conversion(int32_t number, int32_t format);
92 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
93 string zScript;
94 359 std::map<int32_t, script_slot_data > ffcmap;
95 359 std::map<int32_t, script_slot_data > globalmap;
96 359 std::map<int32_t, script_slot_data > genericmap;
97 359 std::map<int32_t, script_slot_data > itemmap;
98 359 std::map<int32_t, script_slot_data > npcmap;
99 359 std::map<int32_t, script_slot_data > ewpnmap;
100 359 std::map<int32_t, script_slot_data > lwpnmap;
101 359 std::map<int32_t, script_slot_data > playermap;
102 359 std::map<int32_t, script_slot_data > dmapmap;
103 359 std::map<int32_t, script_slot_data > screenmap;
104 359 std::map<int32_t, script_slot_data > itemspritemap;
105 359 std::map<int32_t, script_slot_data > comboscriptmap;
106 359 std::map<int32_t, script_slot_data > subscreenmap;
107 void free_newtilebuf();
108 bool combosread=false;
109 bool mapsread=false;
110 bool fixffcs=false;
111 bool fixpolsvoice=false;
112
113 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
114 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
115 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
116 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
117
118 char qstdat_string[2048] = { 0 };
119
120 static zinfo* load_tmp_zi = NULL;
121
122 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
123 const byte clavio[9]={97,109,111,110,103,117,115,0};
124
125 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
126 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
127
128 const char *qst_error[] =
129 {
130 "OK","File not found","Invalid quest file",
131 "Version not supported","Obsolete version",
132 "Missing new data" , /* but let it pass in ZQuest */
133 "Internal error occurred", "Invalid password",
134 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
135 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
136 };
137
138 //for legacy quests -DD
139 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
140 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
141 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
142 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
143 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
144 };
145
146 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
147
148
149 char *byte_conversion(int32_t number, int32_t format)
150 {
151 static char num_str[40];
152
153 if(format==-1) //auto
154 {
155 format=1; //bytes
156
157 if(number>1024)
158 {
159 format=2; //kilobytes
160 }
161
162 if(number>1024*1024)
163 {
164 format=3; //megabytes
165 }
166
167 if(number>1024*1024*1024)
168 {
169 format=4; //gigabytes (dude, what are you doing?)
170 }
171 }
172
173 switch(format)
174 {
175 case 1: //bytes
176 sprintf(num_str,"%db",number);
177 break;
178
179 case 2: //kilobytes
180 sprintf(num_str,"%.2fk",float(number)/1024);
181 break;
182
183 case 3: //megabytes
184 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
185 break;
186
187 case 4: //gigabytes
188 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
189 break;
190
191 default:
192 abort();
193 break;
194 }
195
196 return num_str;
197 }
198
199 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
200 {
201 static char num_str1[40];
202 static char num_str2[40];
203 static char num_str[80];
204
205 if(format1==-1) //auto
206 {
207 format1=1; //bytes
208
209 if(number1>1024)
210 {
211 format1=2; //kilobytes
212 }
213
214 if(number1>1024*1024)
215 {
216 format1=3; //megabytes
217 }
218
219 if(number1>1024*1024*1024)
220 {
221 format1=4; //gigabytes (dude, what are you doing?)
222 }
223 }
224
225 if(format2==-1) //auto
226 {
227 format2=1; //bytes
228
229 if(number2>1024)
230 {
231 format2=2; //kilobytes
232 }
233
234 if(number2>1024*1024)
235 {
236 format2=3; //megabytes
237 }
238
239 if(number2>1024*1024*1024)
240 {
241 format2=4; //gigabytes (dude, what are you doing?)
242 }
243 }
244
245 switch(format1)
246 {
247 case 1: //bytes
248 sprintf(num_str1,"%db",number1);
249 break;
250
251 case 2: //kilobytes
252 sprintf(num_str1,"%.2fk",float(number1)/1024);
253 break;
254
255 case 3: //megabytes
256 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
257 break;
258
259 case 4: //gigabytes
260 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
261 break;
262
263 default:
264 abort();
265 break;
266 }
267
268 switch(format2)
269 {
270 case 1: //bytes
271 sprintf(num_str2,"%db",number2);
272 break;
273
274 case 2: //kilobytes
275 sprintf(num_str2,"%.2fk",float(number2)/1024);
276 break;
277
278 case 3: //megabytes
279 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
280 break;
281
282 case 4: //gigabytes
283 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
284 break;
285
286 default:
287 abort();
288 break;
289 }
290
291 sprintf(num_str, "%s/%s", num_str1, num_str2);
292 return num_str;
293 }
294
295 char *ordinal(int32_t num)
296 {
297 static const char *ending[4] = {"st","nd","rd","th"};
298 static char ord_str[8];
299
300 char *end;
301 int32_t t=(num%100)/10;
302 int32_t n=num%10;
303
304 if(n>=1 && n<4 && t!=1)
305 end = (char *)ending[n-1];
306 else
307 end = (char *)ending[3];
308
309 sprintf(ord_str,"%d%s",num%10000,end);
310 return ord_str;
311 }
312
313 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
314 {
315 int32_t ret;
316 *version=0;
317 *build=0;
318 byte temp_map_count=map_count;
319 byte temp_midi_flags[MIDIFLAGS_SIZE];
320 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
321
322 zquestheader tempheader;
323
324 if(!f)
325 {
326 return qe_invalid;
327 }
328
329 ret=readheader(f, &tempheader);
330
331 if(ret)
332 {
333 return ret;
334 }
335
336 map_count=temp_map_count;
337 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
338 *version=tempheader.zelda_version;
339 *build=tempheader.build;
340 return 0;
341 }
342
343
344 bool find_section(PACKFILE *f, int32_t section_id_requested)
345 {
346
347 if(!f)
348 {
349 return false;
350 }
351
352 int32_t section_id_read;
353 bool catchup=false;
354 word dummy;
355 byte tempbyte;
356 char tempbuf[65536];
357
358
359 switch(section_id_requested)
360 {
361 case ID_RULES:
362 case ID_STRINGS:
363 case ID_MISC:
364 case ID_TILES:
365 case ID_COMBOS:
366 case ID_CSETS:
367 case ID_MAPS:
368 case ID_DMAPS:
369 case ID_DOORS:
370 case ID_ITEMS:
371 case ID_WEAPONS:
372 case ID_COLORS:
373 case ID_ICONS:
374 case ID_INITDATA:
375 case ID_GUYS:
376 case ID_MIDIS:
377 case ID_CHEATS:
378 break;
379
380 default:
381 al_trace("Bad section requested!\n");
382 return false;
383 break;
384 }
385
386 dword section_size;
387
388 //section id
389 if(!p_mgetl(&section_id_read,f))
390 {
391 return false;
392 }
393
394 while(!pack_feof(f))
395 {
396 switch(section_id_read)
397 {
398 case ID_RULES:
399 case ID_STRINGS:
400 case ID_MISC:
401 case ID_TILES:
402 case ID_COMBOS:
403 case ID_CSETS:
404 case ID_MAPS:
405 case ID_DMAPS:
406 case ID_DOORS:
407 case ID_ITEMS:
408 case ID_WEAPONS:
409 case ID_COLORS:
410 case ID_ICONS:
411 case ID_INITDATA:
412 case ID_GUYS:
413 case ID_MIDIS:
414 case ID_CHEATS:
415 catchup=false;
416 break;
417
418 default:
419 break;
420 }
421
422
423 while(catchup)
424 {
425 //section id
426 section_id_read=(section_id_read<<8);
427
428 if(!p_getc(&tempbyte,f))
429 {
430 return false;
431 }
432
433 section_id_read+=tempbyte;
434 }
435
436 if(section_id_read==section_id_requested)
437 {
438 return true;
439 }
440 else
441 {
442 //section version info
443 if(!p_igetw(&dummy,f))
444 {
445 return false;
446 }
447
448 if(!p_igetw(&dummy,f))
449 {
450 return false;
451 }
452
453 //section size
454 if(!p_igetl(&section_size,f))
455 {
456 return false;
457 }
458
459 //pack_fseek(f, section_size);
460 while(section_size>65535)
461 {
462 pfread(tempbuf,65535,f);
463 tempbuf[65535]=0;
464 section_size-=65535;
465 }
466
467 if(section_size>0)
468 {
469 pfread(tempbuf,section_size,f);
470 tempbuf[section_size]=0;
471 }
472 }
473
474 //section id
475 if(!p_mgetl(&section_id_read,f))
476 {
477 return false;
478 }
479 }
480
481 return false;
482 }
483
484
485
486
487
488 bool valid_zqt(PACKFILE *f)
489 {
490
491 //word tiles_used;
492 //word combos_used;
493 //open the file
494 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
495 if(!f)
496 return false;
497
498 //for now, everything else is valid
499 return true;
500
501 /*int16_t version;
502 byte build;
503
504 //read the version and make sure it worked
505 if(!p_igetw(&version,f))
506 {
507 goto error;
508 }
509
510 //read the build and make sure it worked
511 if(!p_getc(&build,f))
512 goto error;
513
514 //read the tile info and make sure it worked
515 if(!p_igetw(&tiles_used,f))
516 {
517 goto error;
518 }
519
520 for (int32_t i=0; i<tiles_used; i++)
521 {
522 if(!pfread(trashbuf,tilesize(tf4Bit),f))
523 {
524 goto error;
525 }
526 }
527
528 //read the combo info and make sure it worked
529 if(!p_igetw(&combos_used,f))
530 {
531 goto error;
532 }
533 for (int32_t i=0; i<combos_used; i++)
534 {
535 if(!pfread(trashbuf,sizeof(newcombo),f))
536 {
537 goto error;
538 }
539 }
540
541 //read the palette info and make sure it worked
542 for (int32_t i=0; i<48; i++)
543 {
544 if(!pfread(trashbuf,newpdTOTAL,f))
545 {
546 goto error;
547 }
548 }
549 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
550 {
551 goto error;
552 }
553 for (int32_t i=0; i<MAXLEVELS; i++)
554 {
555 if(!pfread(trashbuf,PALNAMESIZE,f))
556 {
557 goto error;
558 }
559 }
560
561 //read the sprite info and make sure it worked
562 for (int32_t i=0; i<MAXITEMS; i++)
563 {
564 if(!pfread(trashbuf,sizeof(itemdata),f))
565 {
566 goto error;
567 }
568 }
569
570 for (int32_t i=0; i<MAXWPNS; i++)
571 {
572 if(!pfread(trashbuf,sizeof(wpndata),f))
573 {
574 goto error;
575 }
576 }
577
578 //read the triforce pieces info and make sure it worked
579 for (int32_t i=0; i<8; ++i)
580 {
581 if(!p_getc(&trashbuf,f))
582 {
583 goto error;
584 }
585 }
586
587
588
589 //read the game icons info and make sure it worked
590 for (int32_t i=0; i<4; ++i)
591 {
592 if(!p_igetw(&trashbuf,f))
593 {
594 goto error;
595 }
596 }
597
598 //read the misc colors info and map styles info and make sure it worked
599 if(!pfread(trashbuf,sizeof(zcolors),f))
600 {
601 goto error;
602 }
603
604 //read the template screens and make sure it worked
605 byte num_maps;
606 if(!p_getc(&num_maps,f))
607 {
608 goto error;
609 }
610 for (int32_t i=0; i<TEMPLATES; i++)
611 {
612 if(!pfread(trashbuf,sizeof(mapscr),f))
613 {
614 goto error;
615 }
616 }
617 if (num_maps>1) //dungeon templates
618 {
619 for (int32_t i=0; i<TEMPLATES; i++)
620 {
621 if(!pfread(trashbuf,sizeof(mapscr),f))
622 {
623 goto error;
624 }
625 }
626 }
627
628 //yay! it worked! close the file and say everything was ok.
629 pack_fclose(f);
630 return true;
631
632 error:
633 pack_fclose(f);
634 return false;*/
635 }
636
637 bool valid_zqt(const char *filename)
638 {
639 PACKFILE *f=NULL;
640 bool isvalid;
641 int32_t error;
642 f=open_quest_file(&error, filename, false);
643
644 if(!f)
645 {
646 // setPackfilePassword(NULL);
647 return false;
648 }
649
650 isvalid=valid_zqt(f);
651
652 clear_quest_tmpfile();
653 pack_fclose(f);
654
655 // setPackfilePassword(NULL);
656 return isvalid;
657 }
658
659 /*
660 .qst file history
661
662 .qst files have always been compressed using allegro's packfiles.
663
664 At some point, an encoding layer was added. The two layers look like this:
665
666 1) The top layer is from us. See decode_file_007.
667 [0-24] Preamble "Zelda Classic Quest File"
668 [25-28] Initial decoding seed value.
669 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
670 [last 4] Checksum
671
672 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
673 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
674 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
675 The oldest quests skip the password part.
676
677 Simply, the job of this function is to peel away the top layer.
678
679 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
680 in opening and saving files. There is no version field, so they decryption key is
681 found via trial-by-error (very slow!)
682
683 There are other file types of interest:
684 - .zqt: quest template files, skips top-layer encryption pass
685 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
686 - .qu?: same as above. automated backup files
687 - .qb?: same as above. automated backup files
688 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
689
690 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
691 files are now "slh!.AG ZC Enhanced Quest File".
692 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
693 */
694 687 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
695 {
696
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if (show_progress)
697 {
698 1 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
699 1 }
700
701 687 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
702
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 156 times.
687 if (unencrypted_result.decoded_pf)
703 531 return unencrypted_result.decoded_pf;
704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if (unencrypted_result.not_found)
705 {
706 *open_error = qe_notfound;
707 return nullptr;
708 }
709
710 // Everything below here is legacy code - recently saved quest files will have
711 // returned by now.
712 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
713
714 // Note: although this is primarily for loading .qst files, it can also handle all of the
715 // file types mentioned in the comment above. No need to be told if the file being loaded
716 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
717 156 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
718 156 bool compressed = unencrypted_result.compressed;
719 156 bool encrypted = unencrypted_result.encrypted;
720
721 char tmpfilename[L_tmpnam];
722 156 temp_name(tmpfilename);
723 char percent_done[30];
724 156 int32_t current_method=0;
725
726 PACKFILE *f;
727 156 const char *passwd= encrypted ? datapwd : "";
728
729 // oldquest flag is set when an unencrypted qst file is suspected.
730 156 bool oldquest = false;
731 int32_t ret;
732
733
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(strcmp(filename, "default.qst")!=0)
734 {
735 156 box_out(filename);
736 156 }
737 else
738 {
739 box_out("new quest"); // Or whatever
740 }
741 156 box_out("...");
742 156 box_eol();
743 156 box_eol();
744
745
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(encrypted)
746 {
747 156 box_out("Decrypting...");
748 156 box_save_x();
749 156 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
750
751
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 63 times.
156 if(ret)
752 {
753
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
754 {
755 case 1:
756 box_out("error.");
757 box_eol();
758 box_end(true);
759 *open_error=qe_notfound;
760 return NULL;
761
762 case 2:
763 box_out("error.");
764 box_eol();
765 box_end(true);
766 *open_error=qe_internal;
767 return NULL;
768 // be sure not to delete tmpfilename now...
769 }
770
771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
772 {
773 63 current_method++;
774 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
775 63 box_out(percent_done);
776 63 box_load_x();
777 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
778 63 }
779
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
781 {
782 63 current_method++;
783 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
784 63 box_out(percent_done);
785 63 box_load_x();
786 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
787 63 }
788
789
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
790 {
791 18 current_method++;
792 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 18 box_out(percent_done);
794 18 box_load_x();
795 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
796 18 }
797
798
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
799 {
800 12 current_method++;
801 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 12 box_out(percent_done);
803 12 box_load_x();
804 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
805 12 }
806
807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
808 {
809 oldquest = true;
810 passwd="";
811 }
812 63 }
813
814 156 box_out("okay.");
815 156 box_eol();
816 156 }
817 else
818 {
819 oldquest = true;
820 }
821
822 156 box_out("Opening...");
823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
824
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(!f)
825 {
826 if((compressed==1)&&(errno==EDOM))
827 {
828 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
829 }
830
831 if(!f)
832 {
833 if(!oldquest)
834 {
835 delete_file(tmpfilename);
836 }
837 box_out("error.");
838 box_eol();
839 box_end(true);
840 *open_error=qe_invalid;
841 return NULL;
842 }
843 }
844
845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(!oldquest)
846 {
847 156 delete_file(tmpfilename);
848 156 }
849
850 156 box_out("okay.");
851 156 box_eol();
852
853 156 return f;
854 687 }
855
856 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
857 {
858 char *filename;
859 PACKFILE *f=NULL;
860 int32_t open_error=0;
861
862 strcpy(qstdat_string, "modules/classic/default.qst");
863 if(Header->templatepath[0]==0)
864 {
865 filename=(char *)malloc(2048);
866 strcpy(filename, qstdat_string);
867 }
868 else
869 {
870 // TODO: should be safe to remove this, no one seems to use custom quest templates.
871 filename=Header->templatepath;
872 }
873
874 f=open_quest_file(&open_error, filename, false);
875
876 if(Header->templatepath[0]==0)
877 {
878 free(filename);
879 }
880
881 if(!f)
882 {
883 return NULL;
884 }
885
886 if(validate)
887 {
888 if(!valid_zqt(f))
889 {
890 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
891 pack_fclose(f);
892 clear_quest_tmpfile();
893 return NULL;
894 }
895 }
896
897 return f;
898 }
899
900 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
901 {
902 // We absolutely do not support loading from a template file to initialize data outside the editor.
903 // TODO: move this code into zq/
904 if (get_app_id() != App::zquest) return false;
905
906 combosread=false;
907 mapsread=false;
908 fixffcs=false;
909
910 switch(section_id)
911 {
912 case ID_RULES:
913 case ID_STRINGS:
914 case ID_MISC:
915 case ID_TILES:
916 case ID_COMBOS:
917 case ID_CSETS:
918 case ID_MAPS:
919 case ID_DMAPS:
920 case ID_DOORS:
921 case ID_ITEMS:
922 case ID_WEAPONS:
923 case ID_COLORS:
924 case ID_ICONS:
925 case ID_INITDATA:
926 case ID_GUYS:
927 case ID_MIDIS:
928 case ID_CHEATS:
929 case ID_ITEMDROPSETS:
930 case ID_FAVORITES:
931 break;
932
933 default:
934 return false;
935 break;
936 }
937
938 int32_t ret;
939 word version, build;
940 PACKFILE *f=NULL;
941
942 char deletefilename[1024];
943 deletefilename[0]=0;
944
945 //why is this here?
946 /*
947 if(colordata==NULL)
948 return false;
949 */
950
951 //setPackfilePassword(datapwd);
952 f=open_quest_template(Header, deletefilename, validate);
953
954 if(!f) //no file, nothing to delete
955 {
956 // setPackfilePassword(NULL);
957 return false;
958 }
959
960 ret=get_version_and_build(f, &version, &build);
961
962 if(ret||(version==0))
963 {
964 pack_fclose(f);
965 clear_quest_tmpfile();
966
967 if(deletefilename[0])
968 {
969 delete_file(deletefilename);
970 }
971
972 // setPackfilePassword(NULL);
973 return false;
974 }
975
976 if(!find_section(f, section_id))
977 {
978 al_trace("Can't find section!\n");
979 pack_fclose(f);
980 clear_quest_tmpfile();
981
982 if(deletefilename[0])
983 {
984 delete_file(deletefilename);
985 }
986
987 //setPackfilePassword(NULL);
988 return false;
989 }
990
991 switch(section_id)
992 {
993 case ID_RULES:
994 //rules
995 ret=readrules(f, Header);
996 break;
997
998 case ID_STRINGS:
999 //strings
1000 ret=readstrings(f, Header);
1001 break;
1002
1003 case ID_MISC:
1004 //misc data
1005 ret=readmisc(f, Header, Misc);
1006 break;
1007
1008 case ID_TILES:
1009 //tiles
1010 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1011 break;
1012
1013 case ID_COMBOS:
1014 //combos
1015 clear_combos();
1016 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1017 combosread=true;
1018 break;
1019
1020 case ID_COMBOALIASES:
1021 //combos
1022 ret=readcomboaliases(f, Header, version, build);
1023 break;
1024
1025 case ID_CSETS:
1026 //color data
1027 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1028 break;
1029
1030 case ID_MAPS:
1031 //maps
1032 ret=readmaps(f, Header);
1033 mapsread=true;
1034 break;
1035
1036 case ID_DMAPS:
1037 //dmaps
1038 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1039 break;
1040
1041 case ID_DOORS:
1042 //door combo sets
1043 ret=readdoorcombosets(f, Header);
1044 break;
1045
1046 case ID_ITEMS:
1047 //items
1048 ret=readitems(f, version, build);
1049 break;
1050
1051 case ID_WEAPONS:
1052 //weapons
1053 ret=readweapons(f, Header);
1054 break;
1055
1056 case ID_COLORS:
1057 //misc. colors
1058 ret=readmisccolors(f, Header, Misc);
1059 break;
1060
1061 case ID_ICONS:
1062 //game icons
1063 ret=readgameicons(f, Header, Misc);
1064 break;
1065
1066 case ID_INITDATA:
1067 //initialization data
1068 ret=readinitdata(f, Header);
1069 break;
1070
1071 case ID_GUYS:
1072 //guys
1073 ret=readguys(f, Header);
1074 break;
1075
1076 case ID_MIDIS:
1077 //midis
1078 ret=readtunes(f, Header, tunes);
1079 break;
1080
1081 case ID_CHEATS:
1082 //cheat codes
1083 ret=readcheatcodes(f, Header);
1084 break;
1085
1086 case ID_ITEMDROPSETS:
1087 //item drop sets
1088 // Why is this one commented out?
1089 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1090 break;
1091
1092 case ID_FAVORITES:
1093 // favorite combos and aliases
1094 ret=readfavorites(f, version, build);
1095 break;
1096
1097 default:
1098 ret=-1;
1099 break;
1100 }
1101
1102 pack_fclose(f);
1103 clear_quest_tmpfile();
1104
1105 if(deletefilename[0])
1106 {
1107 delete_file(deletefilename);
1108 }
1109
1110 //setPackfilePassword(NULL);
1111 if(!ret)
1112 {
1113 return true;
1114 }
1115
1116 return false;
1117 }
1118
1119 bool init_tiles(bool validate, zquestheader *Header)
1120 {
1121 return init_section(Header, ID_TILES, NULL, NULL, validate);
1122 }
1123
1124 bool init_combos(bool validate, zquestheader *Header)
1125 {
1126 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1127 }
1128
1129 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1130 {
1131 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1132 }
1133
1134 687 void init_spritelists()
1135 {
1136
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 419 times.
687 if(FFCore.quest_format[vZelda] < 0x255)
1137 {
1138 268 guys.setMax(255);
1139 268 items.setMax(255);
1140 268 Ewpns.setMax(255);
1141 268 Lwpns.setMax(255);
1142 268 chainlinks.setMax(255);
1143 268 decorations.setMax(255);
1144 268 particles.setMax(255);
1145 268 }
1146 else
1147 {
1148 419 guys.setMax(255);
1149 419 items.setMax(255);
1150 419 Ewpns.setMax(255);
1151 419 Lwpns.setMax(255);
1152 419 chainlinks.setMax(255);
1153 419 decorations.setMax(255);
1154 419 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1155 }
1156 687 }
1157
1158 263 bool reset_items(bool validate, zquestheader *Header)
1159 {
1160 263 bool ret = true;
1161
1/2
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
263 if (get_app_id() == App::zquest)
1162 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1163
1164
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 67328 times.
67591 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1165
1166 263 return ret;
1167 }
1168
1169 bool reset_guys()
1170 {
1171 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1172 init_guys(V_GUYS);
1173 return true;
1174 }
1175
1176 bool reset_wpns(bool validate, zquestheader *Header)
1177 {
1178 bool ret = true;
1179 if (get_app_id() == App::zquest)
1180 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1181
1182 for(int32_t i=0; i<MAXWPNS; i++)
1183 reset_weaponname(i);
1184
1185 return ret;
1186 }
1187
1188 bool reset_mapstyles(bool validate, miscQdata *Misc)
1189 {
1190 Misc->colors.blueframe_tile = 20044;
1191 Misc->colors.blueframe_cset = 0;
1192 Misc->colors.triforce_tile = 23461;
1193 Misc->colors.triforce_cset = 1;
1194 Misc->colors.triframe_tile = 18752;
1195 Misc->colors.triframe_cset = 1;
1196 Misc->colors.overworld_map_tile = 16990;
1197 Misc->colors.overworld_map_cset = 2;
1198 Misc->colors.HCpieces_tile = 21160;
1199 Misc->colors.HCpieces_cset = 8;
1200 Misc->colors.dungeon_map_tile = 19651;
1201 Misc->colors.dungeon_map_cset = 8;
1202 return true;
1203 }
1204
1205 309 int32_t get_qst_buffers()
1206 {
1207 309 TheMaps.resize(MAPSCRS);
1208 309 map_autolayers.resize(6);
1209
1210
2/2
✓ Branch 0 taken 42024 times.
✓ Branch 1 taken 309 times.
42333 for(int32_t i(0); i<MAPSCRS; i++)
1211 42024 TheMaps[i].zero_memory();
1212
1213 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1214 309 Z_message("OK\n");
1215
1216 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1217 // (Shoelace's "Hero of Dreams" uses 1415.)
1218 // So let's be a bit generous and allow 4096 initially.
1219 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1220 // I tested it and it worked without flaw on 6/6/11. - L.
1221 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1222 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1223 // See https://discord.com/channels/876899628556091432/992984989073416242
1224 309 msg_strings_size = 8192;
1225
1226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
309 MsgStrings = new MsgStr[msg_strings_size];
1227
1228 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1229
2/2
✓ Branch 0 taken 2531328 times.
✓ Branch 1 taken 309 times.
2531637 for(auto q = 0; q < msg_strings_size; ++q)
1230 {
1231 2531328 MsgStrings[q].clear();
1232 2531328 }
1233
1234
1235
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1236 return 0;
1237
1238
1239
1240
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((DMaps=new dmap[MAXDMAPS])==NULL)
1241 return 0;
1242
1243
1244
1245 309 combobuf.clear();
1246 309 combobuf.resize(MAXCOMBOS);
1247
1248
1249
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1250 return 0;
1251
1252 309 free_newtilebuf();
1253
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1254 return 0;
1255
1256 309 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1257 //Z_message("Performed memset on tiles\n");
1258 309 clear_tiles(newtilebuf);
1259 //Z_message("Performed clear_tiles()\n");
1260
1261
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 9 times.
309 if(is_editor())
1262 {
1263
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1264 return 0;
1265
1266 9 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1267 9 clear_tiles(grabtilebuf);
1268 9 }
1269
1270
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((trashbuf=(byte*)malloc(100000))==NULL)
1271 return 0;
1272
1273 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1274 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1275 // fixed by ensuring there's actually itemdata there.
1276 // If you change this, be sure to update del_qst_buffers, too.
1277
1278
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1279 return 0;
1280
1281 309 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1282 309 itemsbuf++;
1283
1284
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1285 return 0;
1286
1287 309 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1288
1289
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1290 return 0;
1291
1292 309 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1293
1294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
309 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1295 return 0;
1296
1297 309 return 1;
1298 309 }
1299
1300
1301 309 void free_newtilebuf()
1302 {
1303
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 308 times.
309 if(newtilebuf)
1304 {
1305
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 1 times.
214501 for(int32_t i=0; i<NEWMAXTILES; i++)
1306
1/2
✓ Branch 0 taken 214500 times.
✗ Branch 1 not taken.
214500 if(newtilebuf[i].data)
1307 free(newtilebuf[i].data);
1308
1309 1 free(newtilebuf);
1310 1 newtilebuf = 0;
1311 1 }
1312 309 }
1313
1314 void free_grabtilebuf()
1315 {
1316 if(is_editor())
1317 {
1318 if(grabtilebuf)
1319 {
1320 for(int32_t i=0; i<NEWMAXTILES; i++)
1321 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1322
1323 free(grabtilebuf);
1324 grabtilebuf = 0;
1325 }
1326 }
1327 }
1328
1329 void del_qst_buffers()
1330 {
1331 if(MsgStrings) delete[] MsgStrings;
1332
1333 if(DoorComboSets) free(DoorComboSets);
1334
1335 if (DMaps) delete[] DMaps;
1336
1337 combobuf.clear();
1338
1339 if(colordata) free(colordata);
1340
1341 free_newtilebuf();
1342 free_grabtilebuf();
1343
1344 if(trashbuf) free(trashbuf);
1345
1346 // See get_qst_buffers
1347 if(itemsbuf)
1348 {
1349 itemsbuf--;
1350 free(itemsbuf);
1351 }
1352
1353 if(wpnsbuf) free(wpnsbuf);
1354
1355 if(guysbuf) free(guysbuf);
1356
1357 if(combo_class_buf) free(combo_class_buf);
1358 }
1359
1360 18 bool init_palnames()
1361 {
1362 // if(palnames==NULL)
1363 // return false;
1364
1365
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1366 {
1367
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1368 {
1369 case 0:
1370 18 sprintf(palnames[x],"Overworld");
1371 18 break;
1372
1373 case 10:
1374 18 sprintf(palnames[x],"Caves");
1375 18 break;
1376
1377 case 11:
1378 18 sprintf(palnames[x],"Passageways");
1379 18 break;
1380
1381 default:
1382 9162 sprintf(palnames[x],"%c",0);
1383 9162 break;
1384 }
1385 9216 }
1386
1387 18 return true;
1388 }
1389
1390 97522 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1391 {
1392 void *p;
1393
1394
1/2
✓ Branch 0 taken 97522 times.
✗ Branch 1 not taken.
97522 p = _AL_MALLOC(MAX(size, alloc_size));
1395
1396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97522 times.
97522 if(!p)
1397 {
1398 return NULL;
1399 }
1400
1401
1/2
✓ Branch 0 taken 97522 times.
✗ Branch 1 not taken.
97522 if(!pfread(p,size,f))
1402 {
1403 _AL_FREE(p);
1404 return NULL;
1405 }
1406
1407
1/2
✓ Branch 0 taken 97522 times.
✗ Branch 1 not taken.
97522 if(pack_ferror(f))
1408 {
1409 _AL_FREE(p);
1410 return NULL;
1411 }
1412
1413 97522 return p;
1414 97522 }
1415
1416 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1417 static const byte* legacy_skip_flags;
1418
1419 /* read_midi:
1420 * Reads MIDI data from a datafile (this is not the same thing as the
1421 * standard midi file format).
1422 */
1423
1424 10210 static MIDI *read_midi(PACKFILE *f)
1425 {
1426 MIDI *m;
1427 int32_t c;
1428 10210 int16_t divisions=0;
1429 10210 int32_t len=0;
1430
1431 10210 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1432
1433
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!m)
1434 {
1435 return NULL;
1436 }
1437
1438
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1439 {
1440 326720 m->track[c].len = 0;
1441 326720 m->track[c].data = NULL;
1442 326720 }
1443
1444 10210 p_mgetw(&divisions,f);
1445 10210 m->divisions=divisions;
1446
1447
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1448 {
1449 326720 p_mgetl(&len,f);
1450 326720 m->track[c].len=len;
1451
1452
2/2
✓ Branch 0 taken 229198 times.
✓ Branch 1 taken 97522 times.
326720 if(m->track[c].len > 0)
1453 {
1454 97522 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1455
1456
1/2
✓ Branch 0 taken 97522 times.
✗ Branch 1 not taken.
97522 if(!m->track[c].data)
1457 {
1458 destroy_midi(m);
1459 return NULL;
1460 }
1461 97522 }
1462 326720 }
1463
1464 LOCK_DATA(m, sizeof(MIDI));
1465
1466
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1467 {
1468
2/2
✓ Branch 0 taken 97522 times.
✓ Branch 1 taken 229198 times.
326720 if(m->track[c].data)
1469 {
1470 LOCK_DATA(m->track[c].data, m->track[c].len);
1471 97522 }
1472 326720 }
1473
1474 10210 return m;
1475 10210 }
1476
1477 void clear_combo(int32_t i)
1478 {
1479 combobuf[i].clear();
1480 }
1481
1482 void clear_combos()
1483 {
1484 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1485 clear_combo(tmpcounter);
1486 }
1487
1488 void pack_combos()
1489 {
1490 int32_t di = 0;
1491
1492 for(int32_t si=0; si<1024; si+=2)
1493 combobuf[di++] = combobuf[si];
1494
1495 for(; di<1024; di++)
1496 clear_combo(di);
1497 }
1498
1499 686 void reset_tunes(zctune *tune)
1500 {
1501
2/2
✓ Branch 0 taken 172872 times.
✓ Branch 1 taken 686 times.
173558 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1502 {
1503 172872 tune[i].reset();
1504 172872 }
1505 686 }
1506
1507
1508 /*void reset_midi(zcmidi_ *m)
1509 {
1510 m->title[0]=0;
1511 m->loop=1;
1512 m->volume=144;
1513 m->start=0;
1514 m->loop_start=-1;
1515 m->loop_end=-1;
1516 if(m->midi)
1517 {
1518 destroy_midi(m->midi);
1519 }
1520 m->midi=NULL;
1521 }
1522
1523
1524 void reset_midis(zcmidi_ *m)
1525 {
1526 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1527 {
1528 reset_midi(m+i);
1529 }
1530 }
1531 */
1532
1533 void reset_scr(int32_t scr)
1534 {
1535 /*
1536 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1537 for(unsigned i=0; i<sizeof(mapscr); i++)
1538 *(di++) = 0;
1539 TheMaps[scr].valid=mVERSION;
1540 */
1541
1542 TheMaps[scr].zero_memory();
1543 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1544
1545 for(int32_t i=0; i<6; i++)
1546 {
1547 //these will be uncommented later
1548 //TheMaps[scr].layerxsize[i]=16;
1549 //TheMaps[scr].layerysize[i]=11;
1550 TheMaps[scr].layeropacity[i]=255;
1551 }
1552
1553 TheMaps[scr].valid=mVERSION;
1554
1555 }
1556
1557 /* For reference:
1558
1559 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1560 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1561 */
1562
1563 28922 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1564 {
1565
2/2
✓ Branch 0 taken 63938 times.
✓ Branch 1 taken 4377 times.
68315 for(int32_t i=0; i<9; i++)
1566 {
1567
2/2
✓ Branch 0 taken 262433 times.
✓ Branch 1 taken 39699 times.
302132 for(int32_t j=0; j<6; j++)
1568 {
1569
2/2
✓ Branch 0 taken 79398 times.
✓ Branch 1 taken 183035 times.
262433 if(j<4)
1570 {
1571
2/2
✓ Branch 0 taken 158796 times.
✓ Branch 1 taken 24239 times.
183035 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1572 {
1573 24239 return false;
1574 }
1575
1576
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1577 {
1578 return false;
1579 }
1580
1581
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1582 {
1583 return false;
1584 }
1585
1586
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1587 {
1588 return false;
1589 }
1590 158796 }
1591
1592
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1593 {
1594 return false;
1595 }
1596
1597
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1598 {
1599 return false;
1600 }
1601
1602
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1603 {
1604 return false;
1605 }
1606
1607
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1608 {
1609 return false;
1610 }
1611 238194 }
1612
1613
2/2
✓ Branch 0 taken 30639 times.
✓ Branch 1 taken 9060 times.
39699 if(i<2)
1614 {
1615
1/2
✓ Branch 0 taken 9060 times.
✗ Branch 1 not taken.
9060 if(a.flags[i]!=b.flags[i])
1616 {
1617 return false;
1618 }
1619
1620
2/2
✓ Branch 0 taken 9036 times.
✓ Branch 1 taken 24 times.
9060 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1621 {
1622 24 return false;
1623 }
1624
1625
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1626 {
1627 return false;
1628 }
1629
1630
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1631 {
1632 return false;
1633 }
1634
1635
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1636 {
1637 return false;
1638 }
1639 9036 }
1640
1641
2/2
✓ Branch 0 taken 26262 times.
✓ Branch 1 taken 13413 times.
39675 if(i<3)
1642 {
1643
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1644 {
1645 return false;
1646 }
1647
1648
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1649 {
1650 return false;
1651 }
1652
1653
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1654 {
1655 return false;
1656 }
1657
1658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13413 times.
13413 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1659 {
1660 return false;
1661 }
1662 13413 }
1663
1664
2/2
✓ Branch 0 taken 39393 times.
✓ Branch 1 taken 282 times.
39675 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1665 {
1666 282 return false;
1667 }
1668
1669
1/2
✓ Branch 0 taken 39393 times.
✗ Branch 1 not taken.
39393 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1670 {
1671 return false;
1672 }
1673 39393 }
1674
1675 4377 return true;
1676 28922 }
1677
1678 int32_t doortranslations_u[9][4]=
1679 {
1680 {37,38,53,54},
1681 {37,38,39,40},
1682 {37,38,55,56},
1683 {37,38,39,40},
1684 {37,38,53,54},
1685 {37,38,53,54},
1686 {37,38,53,54},
1687 {7,8,23,24},
1688 {7,8,41,42}
1689 };
1690
1691 int32_t doortranslations_d[9][4]=
1692 {
1693 {117,118,133,134},
1694 {135,136,133,134},
1695 {119,120,133,134},
1696 {135,136,133,134},
1697 {117,118,133,134},
1698 {117,118,133,134},
1699 {117,118,133,134},
1700 {151,152,167,168},
1701 {137,138,167,168},
1702 };
1703
1704 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1705 int32_t doortranslations_l[9][6]=
1706 {
1707 {66,67,82,83,98,99},
1708 {66,68,82,84,98,100},
1709 {66,69,82,85,98,101},
1710 {66,68,82,84,98,100},
1711 {66,67,82,83,98,99},
1712 {66,67,82,83,98,99},
1713 {66,67,82,83,98,99},
1714 {64,65,80,81,96,97},
1715 {64,65,80,114,96,97},
1716 };
1717
1718 int32_t doortranslations_r[9][6]=
1719 {
1720
1721 {76,77,92,93,108,109},
1722 {75,77,91,93,107,109},
1723 {74,77,90,93,106,109},
1724 {75,77,91,93,107,109},
1725 {76,77,92,93,108,109},
1726 {76,77,92,93,108,109},
1727 {76,77,92,93,108,109},
1728 {78,79,94,95,110,111},
1729 {78,79,125,95,110,111},
1730 };
1731
1732 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1733 {
1734 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1735 }
1736
1737 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1738 {
1739 //these are here to bypass compiler warnings about unused arguments
1740 840750 map=map;
1741 840750 scr=scr;
1742 840750 pos=pos;
1743
1744 //what does this function do?
1745 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1746 840750 return 2;
1747 }
1748
1749 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1750 {
1751
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1752 {
1753 18423 return 0;
1754 }
1755
1756 DoorComboSet tempdcs;
1757 4425 memset(&tempdcs, 0, sizeof(DoorComboSet));
1758
1759 //up
1760
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1761 {
1762
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1763 {
1764 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1765 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1766 159300 }
1767 39825 }
1768
1769 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1770 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1771 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1772 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1773 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1774 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1775
1776 //down
1777
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1778 {
1779
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1780 {
1781 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1782 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1783 159300 }
1784 39825 }
1785
1786 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1787
1788 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1789 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1790 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1791 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1792 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1793
1794 //left
1795 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1796
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1797 {
1798
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1799 {
1800 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1801 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1802 238950 }
1803 39825 }
1804
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1806 {
1807 if((j!=2)&&(j!=3))
1808 {
1809 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1810 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1811 }
1812 }
1813
1814 4425 tempdcs.bombdoorcombo_l[0]=0;
1815 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1816 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1817 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1818 4425 tempdcs.bombdoorcombo_l[2]=0;
1819 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1820 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1821 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1822
1823 //right
1824
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1825 {
1826
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1827 {
1828 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1829 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1830 238950 }
1831 39825 }
1832
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1834 {
1835 if((j!=2)&&(j!=3))
1836 {
1837 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1838 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1839 }
1840 }
1841
1842 4425 tempdcs.bombdoorcombo_r[0]=0;
1843 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1844 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1845 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1846 4425 tempdcs.bombdoorcombo_r[2]=0;
1847 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1848 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1849 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1850
1851 int32_t k;
1852
1853
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 28922 times.
28970 for(k=0; k<door_combo_set_count; k++)
1854 {
1855
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 24545 times.
28922 if(DoorComboSets[k]==tempdcs)
1856 {
1857 4377 break;
1858 }
1859 24545 }
1860
1861
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 48 times.
4425 if(k==door_combo_set_count)
1862 {
1863 48 DoorComboSets[k]=tempdcs;
1864 48 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1865 48 ++door_combo_set_count;
1866 48 }
1867
1868 4425 return k;
1869 /*
1870 doorcombo_u[9][4];
1871 doorcset_u[9][4];
1872 doorcombo_d[9][4];
1873 doorcset_d[9][4];
1874 doorcombo_l[9][6];
1875 doorcset_l[9][6];
1876 doorcombo_r[9][6];
1877 doorcset_r[9][6];
1878 bombdoorcombo_u[2];
1879 bombdoorcset_u[2];
1880 bombdoorcombo_d[2];
1881 bombdoorcset_d[2];
1882 bombdoorcombo_l[3];
1883 bombdoorcset_l[3];
1884 bombdoorcombo_r[3];
1885 bombdoorcset_r[3];
1886 walkthroughcombo[4];
1887 walkthroughcset[4];
1888 */
1889 22848 }
1890
1891 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1892 {
1893 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1894 }
1895
1896 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1897 {
1898
1899 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1900 }
1901
1902 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1903 {
1904 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1905 }
1906
1907
1908 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1909 {
1910 char temp_pwd[30];
1911 83 memset(temp_pwd,0,30);
1912
1913
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1914 {
1915 75 memcpy(temp_pwd,encrypted_pwd,30);
1916 75 temp_pwd[29]=0;
1917
1918
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1919 {
1920 2250 temp_pwd[i] -= pwdkey;
1921 2250 int32_t t=pwdkey>>15;
1922 2250 pwdkey = (pwdkey<<1)+t;
1923 2250 }
1924 75 }
1925
1926 83 memcpy(pwd,temp_pwd,30);
1927 83 }
1928
1929
1930 275 bool devpwd()
1931 {
1932 #ifdef _DEBUG
1933 return true;
1934 #endif
1935 #if DEVLEVEL > 3
1936 return true;
1937 #endif
1938
1/2
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
275 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1939 }
1940 bool check_questpwd(zquestheader *Header, char *pwd)
1941 {
1942 if(devpwd())
1943 return true;
1944 if((!strcmp(pwd, (char*)clavio)))
1945 return true;
1946 cvs_MD5Context ctx;
1947 uint8_t md5sum[16];
1948
1949 cvs_MD5Init(&ctx);
1950 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1951 cvs_MD5Final(md5sum, &ctx);
1952
1953 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1954 }
1955
1956 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1957 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1958 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1959
1960 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1961 {
1962 char keyfilename[2048];
1963 replace_extension(keyfilename, path, ext, 2047);
1964 if(!exists(keyfilename))
1965 return false;
1966 bool ret = false;
1967
1968 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1969 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1970 char msg[80] = {0};
1971 pfread(msg, 80, fp);
1972 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1973 {
1974 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1975 pack_fclose(fp);
1976 return false;
1977 }
1978 int16_t ver;
1979 byte bld;
1980 p_igetw(&ver, fp);
1981 p_getc(&bld, fp);
1982 pfread(password, QSTPWD_LEN, fp, true);
1983 if(hashed)
1984 {
1985 char unhashed_pw[QSTPWD_LEN] = {0};
1986
1987 char hashmap = 'Z';
1988 hashmap += 'Q';
1989 hashmap += 'U';
1990 hashmap += 'E';
1991 hashmap += 'S';
1992 hashmap += 'T';
1993
1994 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1995 unhashed_pw[q] = password[q] - hashmap;
1996
1997 ret = check_questpwd(Header, unhashed_pw);
1998 }
1999 else ret = check_questpwd(Header, password);
2000 pack_fclose(fp);
2001 zprint2("Found %s Key File '%s' (%s access)\n",
2002 typestr, keyfilename, ret ? "valid" : "invalid");
2003 return ret;
2004 }
2005
2006 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
2007 {
2008 char exedir[PATH_MAX] = {0};
2009 extract_name(path, exedir, FILENAMEALL);
2010 char const* paths[] = {path, exedir};
2011 for(uint keyty : types)
2012 {
2013 if(keyty >= KEYFILE_NUMTY)
2014 continue;
2015 for(char const* p : paths)
2016 {
2017 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
2018 return true;
2019 }
2020 }
2021 return false;
2022 }
2023
2024 377 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2025 {
2026 377 zprint2("\n");
2027 377 zprint2("[QUEST METADATA]\n");
2028
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 8 times.
377 if(qst_num < moduledata.max_quest_files)
2029 8 zprint2("Loading module quest %d\n", qst_num+1);
2030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if(path) zprint2("Loading '%s'\n", path);
2031 377 zprint2("Last saved in version %s\n", tempheader.getVerStr());
2032
2033
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 137 times.
377 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2034
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 137 times.
377 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2035
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 137 times.
377 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2036
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 137 times.
377 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2037
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 363 times.
377 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2038
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 137 times.
377 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2039 377 zprint2("\n");
2040 377 }
2041
2042 687 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2043 {
2044 int32_t dummy;
2045 zquestheader tempheader;
2046 char dummybuf[80];
2047 byte temp_map_count;
2048 byte temp_midi_flags[MIDIFLAGS_SIZE];
2049 word version;
2050 char temp_pwd[30], temp_pwd2[30];
2051 int16_t temp_pwdkey;
2052 cvs_MD5Context ctx;
2053 687 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2054 687 memset(&tempheader, 0, sizeof(tempheader));
2055 687 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2056
2057
2058
2059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
687 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2060 {
2061 Z_message("Unable to read header string\n");
2062 return qe_invalid;
2063 }
2064
2065 // check header
2066
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2067 {
2068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2069 {
2070 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2071 return qe_invalid;
2072 }
2073 24 }
2074
2075 687 int32_t templatepath_len=0;
2076
2077 687 tempheader.external_zinfo = false;
2078 687 read_zinfo = false;
2079
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2080 {
2081 byte padding;
2082
2083
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2084 {
2085 return qe_invalid;
2086 }
2087
2088
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
2089 {
2090 return qe_invalid;
2091 }
2092
2093 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2094
2095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
2096 {
2097 return qe_version;
2098 }
2099
2100 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2101
2102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2103 {
2104 return qe_invalid;
2105 }
2106
2107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(bad_version(tempheader.zelda_version))
2108 {
2109 return qe_obsolete;
2110 }
2111
2112
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2113 {
2114 return qe_invalid;
2115 }
2116
2117
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2118 {
2119 return qe_invalid;
2120 }
2121
2122 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2123
2124
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2125 {
2126 return qe_invalid;
2127 }
2128
2129
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&temp_map_count,f))
2130 {
2131 return qe_invalid;
2132 }
2133
2134 24 FFCore.quest_format[qMapCount] = temp_map_count;
2135
2136
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2137 {
2138 return qe_invalid;
2139 }
2140
2141
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2142 {
2143 return qe_invalid;
2144 }
2145
2146
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2147 {
2148 return qe_invalid;
2149 }
2150
2151
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2152 {
2153 return qe_invalid;
2154 }
2155
2156
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,14,f))
2157 {
2158 return qe_invalid;
2159 }
2160
2161
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2162 {
2163 return qe_invalid;
2164 }
2165
2166
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&dummybuf,f))
2167 {
2168 return qe_invalid;
2169 }
2170
2171
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.version,9,f))
2172 {
2173 return qe_invalid;
2174 }
2175
2176
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2177 {
2178 return qe_invalid;
2179 }
2180 // These fields are expected to end in null bytes!
2181 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2182
2183
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2184 {
2185 return qe_invalid;
2186 }
2187 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2188
2189
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2190 {
2191 return qe_invalid;
2192 }
2193
2194
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2195 {
2196 return qe_invalid;
2197 }
2198
2199
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_pwd,30,f))
2200 {
2201 return qe_invalid;
2202 }
2203
2204 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2205 24 cvs_MD5Init(&ctx);
2206 24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2207 24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2208
2209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2210 {
2211 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2212 // Not anymore...
2213 memset(tempheader.minver,0,17);
2214 tempheader.build=0;
2215 tempheader.use_keyfile=0;
2216 memset(tempheader.old_foo, 0, 9);
2217 }
2218 else
2219 {
2220
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.minver,9,f))
2221 {
2222 return qe_invalid;
2223 }
2224
2225
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.build,f))
2226 {
2227 return qe_invalid;
2228 }
2229
2230 24 FFCore.quest_format[vBuild] = tempheader.build;
2231
2232
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2233 {
2234 return qe_invalid;
2235 }
2236
2237
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,9,f))
2238 {
2239 return qe_invalid;
2240 }
2241 } // starting at minver
2242
2243
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2244 {
2245 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2246 6 }
2247 else
2248 {
2249
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2250 {
2251 return qe_invalid; // starting at rules3
2252 }
2253
2254
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version <= 0x190)
2255 {
2256 12 set_qr(qr_MEANPLACEDTRAPS,0);
2257 12 }
2258 }
2259 24 unpack_qrs();
2260
2261
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2262
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2263 {
2264 18 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2265 18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2266 18 set_qr(qr_BRKBLSHLDS_DEP,1);
2267 18 }
2268
2269
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2270 {
2271 6 byte *mf=temp_midi_flags;
2272
2273
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2274 {
2275 4 mf=(byte*)dummybuf;
2276 4 }
2277
2278
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2279 {
2280 return qe_invalid; // starting at foo2
2281 }
2282
2283
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2284 {
2285 return qe_invalid; // starting at foo2
2286 }
2287 6 }
2288
2289
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2290
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2291 {
2292 18 memset(tempheader.templatepath,0,2048);
2293 18 }
2294 else
2295 {
2296
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2297 {
2298 return qe_invalid;
2299 }
2300 }
2301
2302
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2303
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2304 {
2305 24 tempheader.use_keyfile=0;
2306 24 }
2307 24 }
2308 else
2309 {
2310 //section id
2311
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_mgetl(&dummy,f))
2312 {
2313 return qe_invalid;
2314 }
2315
2316 //section version info
2317
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&version,f))
2318 {
2319 return qe_invalid;
2320 }
2321
2322 663 FFCore.quest_format[vHeader] = version;
2323
2324
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&dummy,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 //section size
2330
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
2331 {
2332 return qe_invalid;
2333 }
2334
2335 //finally... section data
2336
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&tempheader.zelda_version,f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341 663 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2342
2343 //do some quick checking...
2344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(tempheader.zelda_version > ZELDA_VERSION)
2345 {
2346 return qe_version;
2347 }
2348
2349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(bad_version(tempheader.zelda_version))
2355 {
2356 return qe_obsolete;
2357 }
2358
2359
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_getc(&tempheader.build,f))
2360 {
2361 return qe_invalid;
2362 }
2363
2364 663 FFCore.quest_format[vBuild] = tempheader.build;
2365
2366
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 604 times.
663 if(version<3)
2367 {
2368
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!pfread(temp_pwd,30,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2374 {
2375 return qe_invalid;
2376 }
2377
2378 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2379 59 cvs_MD5Init(&ctx);
2380 59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2381 59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2382 59 }
2383 else
2384 {
2385
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2386 {
2387 return qe_invalid;
2388 }
2389 }
2390
2391
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&tempheader.internal,f))
2392 {
2393 return qe_invalid;
2394 }
2395
2396
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_getc(&tempheader.quest_number,f))
2397 {
2398 return qe_invalid;
2399 }
2400
2401 663 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2402
2403 663 size_t versz = version < 8 ? 9 : 16;
2404
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(tempheader.version,versz,f))
2405 {
2406 return qe_invalid;
2407 }
2408
2409 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2410 //needs to be copied as char[9] or stored as a s.str
2411
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(tempheader.minver,versz,f))
2412 {
2413 return qe_invalid;
2414 }
2415
2416 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2417
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2418 {
2419 return qe_invalid;
2420 }
2421 663 tempheader.title[sizeof(tempheader.title)-1] = 0;
2422
2423
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2424 {
2425 return qe_invalid;
2426 }
2427 663 tempheader.author[sizeof(tempheader.author)-1] = 0;
2428
2429
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_getc(&tempheader.use_keyfile,f))
2430 {
2431 return qe_invalid;
2432 }
2433
2434 /*
2435 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2436 {
2437 return qe_invalid;
2438 }
2439 */
2440
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2441 {
2442 return qe_invalid;
2443 }
2444
2445
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(&dummybuf,4,f))
2446 {
2447 return qe_invalid;
2448 }
2449
2450
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2451 {
2452 return qe_invalid;
2453 }
2454
2455
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(dummybuf,14,f))
2456 {
2457 return qe_invalid;
2458 }
2459
2460 663 templatepath_len=sizeof(tempheader.templatepath);
2461
2462
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 59 times.
663 if(version==1)
2463 {
2464 59 templatepath_len=280;
2465 59 }
2466
2467
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(tempheader.templatepath,templatepath_len,f))
2468 {
2469 return qe_invalid;
2470 }
2471
2472
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_getc(&temp_map_count,f))
2473 {
2474 return qe_invalid;
2475 }
2476
2477
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 244 times.
663 if(version>=4)
2478 {
2479
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.version_major,f))
2480 {
2481 return qe_invalid;
2482 }
2483
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.version_minor,f))
2484 {
2485 return qe_invalid;
2486 }
2487
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.version_patch,f))
2488 {
2489 return qe_invalid;
2490 }
2491
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2492 {
2493 return qe_invalid;
2494 }
2495
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2496 {
2497 return qe_invalid;
2498 }
2499
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.new_version_id_beta,f))
2500 {
2501 return qe_invalid;
2502 }
2503
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2504 {
2505 return qe_invalid;
2506 }
2507
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.new_version_id_release,f))
2508 {
2509 return qe_invalid;
2510 }
2511
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2512 {
2513 return qe_invalid;
2514 }
2515
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&tempheader.new_version_id_date_month,f))
2516 {
2517 return qe_invalid;
2518 }
2519
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&tempheader.new_version_id_date_day,f))
2520 {
2521 return qe_invalid;
2522 }
2523
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2524 {
2525 return qe_invalid;
2526 }
2527
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2528 {
2529 return qe_invalid;
2530 }
2531
2532
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.new_version_devsig,256,f))
2533 {
2534 return qe_invalid;
2535 }
2536
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2537 strcpy(tempheader.new_version_devsig, "EmilyV99");
2538
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.new_version_compilername,256,f))
2539 {
2540 return qe_invalid;
2541 }
2542
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.new_version_compilerversion,256,f))
2543 {
2544 return qe_invalid;
2545 }
2546
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.product_name,1024,f))
2547 {
2548 return qe_invalid;
2549 }
2550
2551
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&tempheader.compilerid,f))
2552 {
2553 return qe_invalid;
2554 }
2555
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2556 {
2557 return qe_invalid;
2558 }
2559
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2560 {
2561 return qe_invalid;
2562 }
2563
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2564 {
2565 return qe_invalid;
2566 }
2567
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2568 {
2569 return qe_invalid;
2570 }
2571
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetw(&tempheader.developerid,f))
2572 {
2573 return qe_invalid;
2574 }
2575
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.made_in_module_name,1024,f))
2576 {
2577 return qe_invalid;
2578 }
2579
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.build_datestamp,256,f))
2580 {
2581 return qe_invalid;
2582 }
2583
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.build_timestamp,256,f))
2584 {
2585 return qe_invalid;
2586 }
2587 419 }
2588 else // <4
2589 {
2590 244 tempheader.version_major = 0;
2591 244 tempheader.version_minor = 0;
2592 244 tempheader.version_patch = 0;
2593 244 tempheader.new_version_id_fourth = 0;
2594 244 tempheader.new_version_id_alpha = 0;
2595 244 tempheader.new_version_id_beta = 0;
2596 244 tempheader.new_version_id_gamma = 0;
2597 244 tempheader.new_version_id_release = 0;
2598 244 tempheader.new_version_id_date_year = 0;
2599 244 tempheader.new_version_id_date_month = 0;
2600 244 tempheader.new_version_id_date_day = 0;
2601 244 tempheader.new_version_id_date_hour = 0;
2602 244 tempheader.new_version_id_date_minute = 0;
2603
2604 244 memset(tempheader.new_version_devsig, 0, 256);
2605 244 memset(tempheader.new_version_compilername, 0, 256);
2606 244 memset(tempheader.new_version_compilerversion, 0, 256);
2607 244 memset(tempheader.product_name, 0, 1024);
2608 244 strcpy(tempheader.product_name, "ZQuest Classic");
2609
2610 244 tempheader.compilerid = 0;
2611 244 tempheader.compilerversionnumber_first = 0;
2612 244 tempheader.compilerversionnumber_second = 0;
2613 244 tempheader.compilerversionnumber_third = 0;
2614 244 tempheader.compilerversionnumber_fourth = 0;
2615 244 tempheader.developerid = 0;
2616
2617 244 memset(tempheader.made_in_module_name, 0, 1024);
2618 244 memset(tempheader.build_datestamp, 0, 256);
2619 244 memset(tempheader.build_timestamp, 0, 256);
2620 }
2621
2622
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 244 times.
663 if ( version >= 5 )
2623 {
2624
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(tempheader.build_timezone,6,f))
2625 {
2626 return qe_invalid;
2627 }
2628 419 }
2629 else // < 5
2630 {
2631 244 memset(tempheader.build_timezone, 0, 6);
2632 }
2633
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 419 times.
663 if ( version >= 6 )
2634 {
2635 byte b;
2636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(!p_getc(&b,f))
2637 {
2638 return qe_invalid;
2639 }
2640 419 tempheader.external_zinfo = b?true:false;
2641 419 read_zinfo = true;
2642 419 }
2643
2644
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 244 times.
663 if(version >= 7)
2645 {
2646
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2647 {
2648 return qe_invalid;
2649 }
2650 419 }
2651 else
2652 {
2653 244 tempheader.new_version_is_nightly = false;
2654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
244 if(tempheader.zelda_version < 0x255)
2655 {
2656
2/5
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
✗ Branch 4 not taken.
244 switch(tempheader.zelda_version)
2657 {
2658 case 0x254:
2659 tempheader.version_major = 2;
2660 tempheader.version_minor = 54;
2661 break;
2662 case 0x250:
2663
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 81 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 19 times.
✓ Branch 15 taken 11 times.
185 switch(tempheader.build)
2664 {
2665 case 19:
2666 tempheader.version_major = 2;
2667 tempheader.version_minor = 50;
2668 tempheader.new_version_id_gamma = 1;
2669 break;
2670 case 20:
2671 tempheader.version_major = 2;
2672 tempheader.version_minor = 50;
2673 tempheader.new_version_id_gamma = 2;
2674 break;
2675 case 21:
2676 tempheader.version_major = 2;
2677 tempheader.version_minor = 50;
2678 tempheader.new_version_id_gamma = 3;
2679 break;
2680 case 22:
2681 tempheader.version_major = 2;
2682 tempheader.version_minor = 50;
2683 tempheader.new_version_id_gamma = 4;
2684 break;
2685 case 23:
2686 tempheader.version_major = 2;
2687 tempheader.version_minor = 50;
2688 tempheader.new_version_id_gamma = 5;
2689 break;
2690 case 24:
2691 28 tempheader.version_major = 2;
2692 28 tempheader.version_minor = 50;
2693 28 tempheader.new_version_id_release = -1;
2694 28 break;
2695 case 25:
2696 tempheader.version_major = 2;
2697 tempheader.version_minor = 50;
2698 tempheader.version_patch = 1;
2699 tempheader.new_version_id_gamma = 1;
2700 break;
2701 case 26:
2702 24 tempheader.version_major = 2;
2703 24 tempheader.version_minor = 50;
2704 24 tempheader.version_patch = 1;
2705 24 tempheader.new_version_id_gamma = 2;
2706 24 break;
2707 case 27:
2708 tempheader.version_major = 2;
2709 tempheader.version_minor = 50;
2710 tempheader.version_patch = 1;
2711 tempheader.new_version_id_gamma = 3;
2712 break;
2713 case 28:
2714 6 tempheader.version_major = 2;
2715 6 tempheader.version_minor = 50;
2716 6 tempheader.version_patch = 1;
2717 6 tempheader.new_version_id_release = -1;
2718 6 break;
2719 case 29:
2720 81 tempheader.version_major = 2;
2721 81 tempheader.version_minor = 50;
2722 81 tempheader.version_patch = 2;
2723 81 tempheader.new_version_id_release = -1;
2724 81 break;
2725 case 30:
2726 tempheader.version_major = 2;
2727 tempheader.version_minor = 50;
2728 tempheader.version_patch = 3;
2729 tempheader.new_version_id_gamma = 1;
2730 break;
2731 case 31:
2732 16 tempheader.version_major = 2;
2733 16 tempheader.version_minor = 53;
2734 16 tempheader.new_version_id_gamma = -1;
2735 16 break;
2736 case 32:
2737 19 tempheader.version_major = 2;
2738 19 tempheader.version_minor = 53;
2739 19 tempheader.new_version_id_release = -1;
2740 19 break;
2741 case 33:
2742 11 tempheader.version_major = 2;
2743 11 tempheader.version_minor = 53;
2744 11 tempheader.version_patch = 1;
2745 11 break;
2746 }
2747 185 break;
2748
2749 case 0x211:
2750 tempheader.version_major = 2;
2751 tempheader.version_minor = 11;
2752 tempheader.new_version_id_beta = tempheader.build;
2753 break;
2754 case 0x210:
2755 59 tempheader.version_major = 2;
2756 59 tempheader.version_minor = 10;
2757 59 tempheader.new_version_id_beta = tempheader.build;
2758 59 break;
2759 }
2760 244 }
2761 }
2762
2763
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 559 times.
663 if (version>=9)
2764 {
2765 104 std::string version_string;
2766
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getcstr(&version_string, f))
2767 {
2768 return qe_invalid;
2769 }
2770
2771 104 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2772 104 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2773
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
104 }
2774 else
2775 {
2776 559 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2777 }
2778
2779
3/4
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 655 times.
663 if(printmetadata || __isZQuest)
2780 {
2781 8 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2782 8 }
2783 }
2784
2785 //{ Version Warning
2786 687 int32_t vercmp = tempheader.compareVer();
2787 687 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2788 687 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2789
4/6
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 583 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 104 times.
791 if(vercmp > 0 || (!vercmp &&
2790
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 (astatecmp > 0 || (!astatecmp &&
2791 104 avercmp > 0))))
2792 {
2793 bool r = true;
2794 if(loadquest_report)
2795 {
2796 enter_sys_pal();
2797 AlertDialog("Quest saved in newer version",
2798 "This quest was last saved in a newer version of ZQuest."
2799 " Attempting to load this quest may not work correctly; to"
2800 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2801 "\n\nWould you like to continue loading anyway? (Not recommended)",
2802 [&](bool ret,bool)
2803 {
2804 r = ret;
2805 }).show();
2806 exit_sys_pal();
2807 }
2808 if(!r)
2809 return qe_silenterr;
2810 }
2811
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 else if(tempheader.compareDate() > 0)
2812 {
2813 bool r = true;
2814 if(loadquest_report)
2815 {
2816 enter_sys_pal();
2817 AlertDialog("Quest saved in newer build",
2818 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2819 " issues loading in this build."
2820 "\n{}"
2821 "\n\nWould you like to continue loading anyway?",
2822 tempheader.getVerCmpStr()),
2823 [&](bool ret,bool)
2824 {
2825 r = ret;
2826 }).show();
2827 exit_sys_pal();
2828 }
2829 if(!r)
2830 return qe_silenterr;
2831 }
2832 //}
2833
2834 687 read_ext_zinfo = tempheader.external_zinfo;
2835
2836 687 memcpy(Header, &tempheader, sizeof(tempheader));
2837 687 map_count=temp_map_count;
2838 687 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2839
2840 687 unpack_qrs();
2841
2842 687 return 0;
2843 687 }
2844
2845 678 int32_t readrules(PACKFILE *f, zquestheader *Header)
2846 {
2847
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 23 times.
678 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 678 times.
678 if (should_skip)
2849 return 0;
2850
2851 int32_t dummy;
2852 zquestheader tempheader;
2853 678 word s_version=0;
2854 678 dword compatrule_version=0;
2855
2856 678 memcpy(&tempheader, Header, sizeof(tempheader));
2857
2858
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 663 times.
678 if(tempheader.zelda_version >= 0x193)
2859 {
2860 //section version info
2861
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
2862 {
2863 return qe_invalid;
2864 }
2865
2866 663 FFCore.quest_format[vRules] = s_version;
2867
2868
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&dummy,f))
2869 {
2870 return qe_invalid;
2871 }
2872
2873
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 419 times.
663 if(s_version > 16)
2874 {
2875
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&compatrule_version,f))
2876 {
2877 return qe_invalid;
2878 }
2879 419 }
2880 663 FFCore.quest_format[vCompatRule] = compatrule_version;
2881
2882 //section size
2883
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
2884 {
2885 return qe_invalid;
2886 }
2887
2888
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 419 times.
663 if ( s_version < 15 )
2889 {
2890 //finally... section data
2891
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2892 {
2893 return qe_invalid;
2894 }
2895 244 }
2896 else
2897 {
2898
2899
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2900 {
2901 return qe_invalid;
2902 }
2903
2904 }
2905 663 }
2906
2907 //al_trace("Rules version %d\n", s_version);
2908 //{ bunch of compat stuff
2909 678 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2910
2911 678 unpack_qrs();
2912
2913
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 82 times.
678 if(s_version<2)
2914 {
2915 82 set_qr(14,0);
2916 82 set_qr(27,0);
2917 82 set_qr(28,0);
2918 82 set_qr(29,0);
2919 82 set_qr(30,0);
2920 82 set_qr(32,0);
2921 82 set_qr(36,0);
2922 82 set_qr(49,0);
2923 82 set_qr(50,0);
2924 82 set_qr(51,0);
2925 82 set_qr(68,0);
2926 82 set_qr(75,0);
2927 82 set_qr(76,0);
2928 82 set_qr(98,0);
2929 82 set_qr(110,0);
2930 82 set_qr(113,0);
2931 82 set_qr(116,0);
2932 82 set_qr(102,0);
2933 82 set_qr(132,0);
2934 82 }
2935
2936 //Now, do any updates...
2937
5/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
678 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2938 {
2939 90 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2940 90 set_qr(qr_REPLACEOPENDOORS, 1);
2941 90 set_qr(qr_OLDLENSORDER, 1);
2942 90 set_qr(qr_NOFAIRYGUYFIRES, 1);
2943 90 set_qr(qr_TRIGGERSREPEAT, 1);
2944 90 }
2945
2946
5/6
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
702 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2947 {
2948 31 set_qr(qr_WALLFLIERS,1);
2949 31 }
2950
2951
5/6
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
702 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2952 {
2953 31 set_qr(qr_NOBOMBPALFLASH,1);
2954 31 }
2955
2956
5/6
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
702 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2957 {
2958 35 set_qr(qr_NOSCROLLCONTINUE,1);
2959 35 }
2960
2961
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 82 times.
706 if(tempheader.zelda_version <= 0x210)
2962 {
2963 82 set_qr(qr_ARROWCLIP,1);
2964 82 }
2965
2966
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 59 times.
674 if(tempheader.zelda_version == 0x210)
2967 {
2968 59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2969 59 set_qr(qr_CMBCYCLELAYERS, 0);
2970 59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2971 59 }
2972
2973
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 82 times.
674 if(tempheader.zelda_version <= 0x210)
2974 {
2975 82 set_qr(qr_OLDSTYLEWARP,1);
2976 82 set_qr(qr_210_WARPRETURN,1);
2977 82 }
2978
2979 //might not be correct
2980
2/2
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 23 times.
674 if(tempheader.zelda_version < 0x210)
2981 {
2982 23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2983 23 set_qr(qr_OLDTRIBBLES_DEP,1);
2984 23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2985 23 }
2986
2987
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 82 times.
674 if(tempheader.zelda_version < 0x211)
2988 {
2989 82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2990 82 }
2991
2992
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 669 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 652 times.
674 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2993 {
2994 22 set_qr(qr_192b163_WARP,1);
2995 22 }
2996
2997
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 59 times.
674 if(tempheader.zelda_version == 0x210)
2998 {
2999 59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3000 59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3001 59 set_qr(qr_DMGCOMBOPRI, 0);
3002 59 }
3003
3004
5/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
674 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3005 {
3006 90 set_qr(qr_OLDPICKUP,1);
3007 90 }
3008
3009
5/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
706 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3010 {
3011 90 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3012 90 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3013 90 }
3014
3015
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 82 times.
706 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3016 {
3017 82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3018 82 }
3019
3020
4/4
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 489 times.
✓ Branch 2 taken 157 times.
✓ Branch 3 taken 28 times.
674 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3021 {
3022 28 set_qr(qr_PEAHATCLOCKVULN, 1);
3023 28 }
3024
3025
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 173 times.
674 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3026 {
3027 90 set_qr(qr_OLD_DOORREPAIR, 1);
3028 90 }
3029
3030
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 205 times.
674 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3031 {
3032 90 set_qr(qr_OLD_SECRETMONEY, 1);
3033 90 }
3034
3035
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 153 times.
706 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3036 {
3037 142 set_qr(qr_OLD_POTION_OR_HC, 1);
3038 142 }
3039
3040
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 153 times.
706 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3041 {
3042 142 set_qr(qr_OFFSCREENWEAPONS, 1);
3043 142 }
3044
3045 //Bombchu fix.
3046
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 185 times.
706 if(tempheader.zelda_version == 0x250)
3047 {
3048
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 28 times.
185 if ( tempheader.build == 24 ) //2.50.0
3049 {
3050 28 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3051 28 }
3052
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 6 times.
185 if ( tempheader.build == 28 ) //2.50.1
3053 {
3054 6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3055 6 }
3056
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 81 times.
185 if ( tempheader.build == 29 ) //2.50.2
3057 {
3058 81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3059 81 }
3060
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if ( tempheader.build == 30 ) //2.50.3RC1
3061 {
3062 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3063 }
3064 185 }
3065
3066
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 149 times.
706 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3067 {
3068 // qr_OFFSETEWPNCOLLISIONFIX
3069 // All 'official' quests need this disabled.
3070 // All 2.10 and lower quests need this enabled to preseve compatability.
3071 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3072
3073 //~Gleeok
3074 148 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3075
3076 // Broke in build 695
3077
3/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
148 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3078 58 set_qr(qr_BROKENSTATUES, 1);
3079 140 }
3080
11/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 668 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 703 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 703 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 686 times.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
708 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
3081 {
3082 22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3083 22 }
3084
9/10
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 523 times.
✓ Branch 2 taken 512 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 430 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 419 times.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 419 times.
708 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3085 {
3086 278 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3087 278 }
3088
3089
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3090 {
3091 82 set_qr(qr_OLD_210_WATER, 1);
3092 82 }
3093
3094
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3095 {
3096 267 set_qr(qr_STEP_IS_FLOAT,0);
3097 267 }
3098
3099
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if ( tempheader.zelda_version < 0x250 )
3100 {
3101 82 set_qr(qr_8WAY_SHOT_SFX, 1);
3102 82 }
3103
3104
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version < 3)
3105 {
3106 82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3107 82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3108 82 }
3109
3110
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<4)
3111 {
3112 82 set_qr(10,0);
3113 82 }
3114
3115
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<5)
3116 {
3117 82 set_qr(27,0);
3118 82 }
3119
3120
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<6)
3121 {
3122 82 set_qr(46,0);
3123 82 }
3124
3125
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<7) // January 2008
3126 {
3127 82 set_qr(qr_HEARTSREQUIREDFIX,0);
3128 82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3129 82 }
3130
3131
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 604 times.
686 if(s_version<8)
3132 {
3133 82 set_qr(12, 0);
3134 82 }
3135 else
3136 {
3137 604 set_bit(deprecated_rules, 12, 0);
3138 }
3139
3140
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<9) // October 2008
3141 {
3142 82 set_qr(qr_NOROPE2FLASH_DEP,0);
3143 82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3144 82 set_qr(qr_GHINI2BLINK_DEP,0);
3145 82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3146 82 }
3147
3148
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<10) // December 2008
3149 {
3150 82 set_qr(qr_NOCLOCKS_DEP,0);
3151 82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3152 82 }
3153
3154
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<11) // April 2009
3155 {
3156 82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3157 82 }
3158
3159 // This served no purpose.
3160 // if(s_version<12) // December 2009
3161 // {
3162 // set_qr(qr_BRKBLSHLDS_DEP,0);
3163 // set_qr(qr_OLDTRIBBLES_DEP,0);
3164 // }
3165
3166 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3167
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version < 13)
3168 {
3169 82 set_qr(qr_SHOPCHEAT, 1);
3170 82 }
3171
3172 // Not entirely sure this is the best place for this...
3173 //2.50.2 bitmap offset fix
3174 686 memset(extra_rules, 0, EXTRARULES_SIZE);
3175
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 127 times.
686 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3176 {
3177 140 set_er(er_BITMAPOFFSET, 1);
3178 140 set_qr(qr_BITMAPOFFSETFIX, 1);
3179 140 }
3180 //required because quest templates also used this bit, although
3181 //it never did anything, before. -Z
3182
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 185 times.
686 if ( tempheader.zelda_version == 0x250 )
3183 {
3184
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 88 times.
185 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3185 {
3186 97 set_er(er_BITMAPOFFSET, 0);
3187 97 set_qr(qr_BITMAPOFFSETFIX, 0);
3188 97 }
3189 185 }
3190
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 if ( tempheader.zelda_version == 0x254 )
3191 {
3192 set_er(er_BITMAPOFFSET, 0);
3193 set_qr(qr_BITMAPOFFSETFIX, 0);
3194 }
3195
3/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
686 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3196 {
3197 set_er(er_BITMAPOFFSET, 0);
3198 set_qr(qr_BITMAPOFFSETFIX, 0);
3199 }
3200 //optimise fast drawing for older versions.
3201
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3202 {
3203 267 set_qr(qr_OLDSPRITEDRAWS, 1);
3204 267 }
3205 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3206 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3207 //older quests can set the rule by hand. We need a new qst.dat again.
3208
4/6
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 419 times.
✓ Branch 3 taken 267 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3209 {
3210 set_qr(qr_OLDEWPNPARENT, 1);
3211 }
3212
4/6
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 419 times.
✓ Branch 3 taken 267 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3213 {
3214 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3215 }
3216
4/6
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 419 times.
✓ Branch 3 taken 267 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3217 {
3218 set_qr(qr_OLDQUESTMISC, 1);
3219 }
3220
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if ( tempheader.zelda_version < 0x254 )
3221 {
3222 267 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3223 267 set_qr(qr_OLDEWPNPARENT, 0);
3224 267 set_qr(qr_OLDQUESTMISC, 0);
3225 267 }
3226
3227 //item scripts continue to run
3228
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3229 {
3230 267 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3231 267 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3232 267 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3233 267 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3234 267 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3235 267 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3236 267 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3237 267 }
3238
3239
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3240 {
3241 267 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3242 267 }
3243
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3244 {
3245 267 set_qr(qr_TRACESCRIPTIDS, 0);
3246 267 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3247 267 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3248 267 set_qr(qr_PARSER_250DIVISION,1);
3249 267 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3250 267 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3251 267 set_qr(qr_PARSER_FORCE_INLINE,0);
3252 267 set_qr(qr_PARSER_BINARY_32BIT,0);
3253
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 7 times.
267 if ( get_qr(qr_SELECTAWPN) )
3254 {
3255 7 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3256 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3257 //Now they **do**, unless you disable that behaviour.
3258 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3259 //now enable the disable L/R item swap on load.
3260 7 }
3261
3262 267 }
3263
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3264 {
3265 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3266 267 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3267 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3268 //animations ending earlier than they should.
3269 267 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3270 //Enemies would ignore solidity on the top half of combos
3271 267 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3272 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3273 267 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3274 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3275 267 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3276 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3277 267 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3278 267 }
3279
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if ( tempheader.zelda_version < 0x255 )
3280 {
3281 267 set_qr(qr_NOFFCWAITDRAW, 1);
3282 267 set_qr(qr_NOITEMWAITDRAW, 1);
3283 267 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3284 267 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3285 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3286 267 }
3287
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3288 {
3289 267 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3290 267 }
3291
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3292 {
3293 267 set_qr(qr_OLD_PRINTF_ARGS, 1);
3294 267 }
3295
3296
3297
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3298 {
3299 267 set_qr(qr_BROKEN_RING_POWER, 1);
3300 267 }
3301
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3302 {
3303 267 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3304 267 }
3305
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3306 {
3307 267 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3308 267 }
3309
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3310 {
3311 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3312
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(get_qr(qr_SET_XBUTTON_ITEMS))
3313 set_qr(qr_SET_YBUTTON_ITEMS,1);
3314 267 }
3315
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3316 {
3317 267 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3318 267 }
3319
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3320 {
3321 267 set_qr(qr_OLD_CHEST_COLLISION,1);
3322 267 }
3323
3324
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if ( tempheader.zelda_version < 0x254 )
3325 {
3326 267 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3327 267 }
3328 //Sideview spikes in 2.50.0
3329
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 133 times.
686 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3330 {
3331 134 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3332 134 }
3333 //more 2.50 fixes -Z
3334
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 139 times.
✓ Branch 5 taken 46 times.
686 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3335 {
3336 221 set_qr(qr_MELEEMAGICCOST, 0);
3337 221 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3338 221 set_qr(qr_OLDMIRRORCOMBOS, 1);
3339 221 set_qr(qr_BROKENBOOKCOST, 1);
3340 221 set_qr(qr_BROKENCHARINTDRAWING, 1);
3341
3342 221 }
3343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
686 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3344 {
3345 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3346 set_qr(qr_MELEEMAGICCOST, 1);
3347 }
3348
3349
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 if(tempheader.zelda_version < 0x193)
3350 {
3351 23 set_qr(qr_SHORTDGNWALK, 1);
3352 23 }
3353
3354
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(tempheader.zelda_version < 0x255)
3355 {
3356 267 set_qr(qr_OLDINFMAGIC, 1);
3357 267 }
3358
3359
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3360 {
3361 82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3362 82 }
3363
3364
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3365 {
3366 267 set_qr(qr_OLD_F6,1);
3367 267 }
3368
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3369 {
3370 267 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3371 267 }
3372
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3373 {
3374 267 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3375 267 }
3376
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
686 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3377 {
3378 267 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3379 267 }
3380 //}
3381
3382
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3383 267 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3384
3385
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 2) //Old CSet2 Handling
3386 267 set_qr(qr_OLDCS2,1);
3387
3388
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3389 267 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3390
3391
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3392 267 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3393
3394
4/4
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 419 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 185 times.
686 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3395 185 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3396
3397
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3398 267 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3399
3400
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3401 267 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3402
3403
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3404 267 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3405
3406
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 9)
3407 {
3408 //Hardcoded BS Patras
3409 267 set_qr(qr_HARDCODED_BS_PATRA,1);
3410 //Hardcoded Patra Inner Eye offsets
3411 267 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3412 //Broken 'Big enemy' animation style
3413 267 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3414 //Broken Attribute 31/32
3415 267 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3416 267 }
3417
3418
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 10) //Shared candle use limits
3419 267 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3420
3421
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 11) //No cross-screen return points
3422 267 set_qr(qr_OLD_RESPAWN_POINTS,1);
3423
3424
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 12)
3425 {
3426 //Old fire trail duration
3427 267 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3428 //Old Intro String in Ganon Room Behavior
3429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3430 267 else set_qr(qr_GANONINTRO,1);
3431 267 }
3432
3433
3/4
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 419 times.
✓ Branch 2 taken 267 times.
✗ Branch 3 not taken.
686 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3434 set_qr(qr_ANONE_NOANIM,1);
3435
3436
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 14) //Old Bridge Combo Behavior
3437 267 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3438
3439
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 15) //Broken Z3 Animation
3440 267 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3441
3442
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3443 267 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3444
3445
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 17)
3446 {
3447 //Old Quake/DrawYOffset behavior
3448 //set_qr(qr_OLD_DRAWOFFSET,1);
3449 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3450 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3451 267 }
3452
3453
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 18)
3454 {
3455 //Broken DrawScreen Derivative Functions
3456 267 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3457 //Scrolling Cancels Charge
3458 267 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3459 267 }
3460
3461
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3462 267 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3463
3464
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 20)
3465 267 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3466
3467
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 21)
3468 {
3469 267 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3470 267 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3471 267 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3472 267 set_qr(qr_OLD_BUG_NET,1);
3473 267 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3474 267 }
3475
3476
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 22)
3477 267 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3478
3479
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 23)
3480 267 set_qr(qr_OLD_HALF_MAGIC,1);
3481
3482
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 24)
3483 {
3484 267 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3485 267 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3486 267 }
3487
3488
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 25)
3489 {
3490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3491 267 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3492 267 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3493 267 }
3494
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 26)
3495 {
3496 267 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3497 267 set_qr(qr_POLVIRE_NO_SHADOW,1);
3498 267 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3499 267 }
3500
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3501 {
3502
2/2
✓ Branch 0 taken 80367 times.
✓ Branch 1 taken 267 times.
80634 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3503 80367 set_qr(q,0);
3504
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 267 times.
801 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3505 534 set_qr(q,0);
3506 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3507 267 }
3508
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 28)
3509 272 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3510
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 29)
3511 272 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3512
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 30)
3513 {
3514 272 set_qr(qr_DECO_2_YOFFSET,1);
3515 272 set_qr(qr_SCREENSTATE_80s_BUG,1);
3516 272 }
3517
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 31)
3518 {
3519 272 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3520 272 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3521 272 }
3522
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 32)
3523 272 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3524
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 33)
3525 272 set_qr(qr_NO_LIFT_SPRITE,1);
3526
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 272 times.
686 if(compatrule_version < 34)
3527 {
3528 272 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3529 272 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3530 272 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3531 272 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3532 272 }
3533
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 274 times.
686 if(compatrule_version < 35)
3534 {
3535 274 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3536 274 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3537 274 }
3538
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 274 times.
686 if(compatrule_version < 36)
3539 274 set_qr(qr_OLD_SHALLOW_SFX,1);
3540
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 278 times.
686 if(compatrule_version < 37)
3541 278 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3542
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 278 times.
686 if(compatrule_version < 38)
3543 278 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3544
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 278 times.
686 if(compatrule_version < 39)
3545 278 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3546
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 278 times.
686 if(compatrule_version < 40)
3547 278 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3548
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 280 times.
686 if(compatrule_version < 41)
3549 280 set_qr(qr_BROKENHITBY,1);
3550
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 280 times.
686 if(compatrule_version < 42)
3551 280 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3552
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 280 times.
686 if(compatrule_version < 43)
3553 280 set_qr(qr_OLD_BOMB_HITBOXES,1);
3554
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 280 times.
686 if(compatrule_version < 44)
3555 280 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3556
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 280 times.
686 if(compatrule_version < 45)
3557 280 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3558
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 280 times.
686 if(compatrule_version < 46)
3559 280 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3560
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 47)
3561 {
3562 285 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3563 285 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3564 285 }
3565
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 48)
3566 285 set_qr(qr_OLD_GUY_HANDLING,1);
3567
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 49)
3568 285 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3569
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 50)
3570 285 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3571
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 51)
3572 285 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3573
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if (compatrule_version < 52)
3574 285 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3575
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 53)
3576 {
3577 285 set_qr(qr_OLD_SUBSCR,1);
3578 285 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3579 285 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3580 285 }
3581
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 54)
3582 285 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3583
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 55)
3584 285 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3585
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 56)
3586 285 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3587
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 57)
3588 285 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3589
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 58)
3590 285 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3591
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 59)
3592 285 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3593
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 60)
3594 285 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3595
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 61)
3596 285 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3597
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 62)
3598 285 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3599
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 63)
3600 {
3601 285 set_qr(qr_BROKEN_LIFTSWIM,1);
3602 285 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3603 285 }
3604
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 285 times.
686 if(compatrule_version < 64)
3605 285 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3606
2/2
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 309 times.
686 if(compatrule_version < 65)
3607 309 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3608
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 582 times.
686 if(compatrule_version < 66)
3609 582 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3610
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 582 times.
686 if(compatrule_version < 67)
3611 582 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3612
3613 686 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3614
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 267 times.
686 if (s_version < 16)
3615 267 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3616
3617 686 memcpy(Header, &tempheader, sizeof(tempheader));
3618
3619 686 return 0;
3620 686 }
3621
3622 5756766 void init_msgstr(MsgStr *str)
3623 {
3624 5756766 str->s = "";
3625 5756766 str->s.shrink_to_fit();
3626 5756766 str->nextstring=0;
3627 5756766 str->tile=0;
3628 5756766 str->cset=0;
3629 5756766 str->trans=false;
3630 5756766 str->font=font_zfont;
3631 5756766 str->y=32;
3632 5756766 str->sfx=18;
3633 5756766 str->listpos=0;
3634 5756766 str->x=24;
3635 5756766 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3636 5756766 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3637 5756766 str->hspace=0;
3638 5756766 str->vspace=0;
3639 5756766 str->stringflags=0;
3640 5756766 str->margins[up] = 8;
3641 5756766 str->margins[down] = 0;
3642 5756766 str->margins[left] = 8;
3643 5756766 str->margins[right] = 8;
3644 5756766 str->portrait_tile = 0;
3645 5756766 str->portrait_cset = 0;
3646 5756766 str->portrait_x = 0;
3647 5756766 str->portrait_y = 0;
3648 5756766 str->portrait_tw = 1;
3649 5756766 str->portrait_th = 1;
3650 5756766 str->shadow_type = 0;
3651 5756766 str->shadow_color = 0;
3652 5756766 str->drawlayer = 6;
3653 5756766 }
3654
3655 686 void init_msgstrings(int32_t start, int32_t end)
3656 {
3657
2/4
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 686 times.
686 if(end <= start || end-start > msg_strings_size)
3658 return;
3659
3660
2/2
✓ Branch 0 taken 5619712 times.
✓ Branch 1 taken 686 times.
5620398 for(int32_t i=start; i<end; i++)
3661 {
3662 5619712 init_msgstr(&MsgStrings[i]);
3663 5619712 MsgStrings[i].listpos=i;
3664 5619712 }
3665
3666
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 if(start==0)
3667 {
3668 686 MsgStrings[0].s = "(None)";
3669 686 MsgStrings[0].listpos = 0;
3670 686 }
3671 686 }
3672
3673 687 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3674 {
3675
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3676
3677 687 MsgStr tempMsgString;
3678
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 init_msgstr(&tempMsgString);
3679
3680 687 word temp_msg_count=0;
3681 word temp_expansion[16];
3682 687 memset(temp_expansion, 0, 16*sizeof(word));
3683 687 char buf[8193] = {0};
3684
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(Header->zelda_version < 0x193)
3685 {
3686 byte tempbyte;
3687 24 int32_t strings_to_read=0;
3688
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3689
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3690
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3691
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3692 {
3693 18 strings_to_read=128;
3694 18 temp_msg_count=Header->old_str_count;
3695
3696 // Some sort of string count corruption seems to be common in old quests
3697
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3698 {
3699 temp_msg_count=128;
3700 }
3701 18 }
3702
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3703 {
3704 strings_to_read=255;
3705 temp_msg_count=Header->old_str_count;
3706 }
3707 else
3708 {
3709
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3710 {
3711 return qe_invalid;
3712 }
3713
3714 6 strings_to_read=temp_msg_count;
3715
3716
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3717 {
3718 Z_message("Reallocating string buffer...\n");
3719
3720 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3721 // return qe_nomem;
3722
3723 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3724 delete[] MsgStrings;
3725 MsgStrings = new MsgStr[MAXMSGS];
3726 msg_strings_size = MAXMSGS;
3727 for(auto q = 0; q < msg_strings_size; ++q)
3728 {
3729 MsgStrings[q].clear();
3730 }
3731 }
3732 }
3733
3734 //reset the message strings
3735
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3736
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3737
3738
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3739 {
3740
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3741 2550 tempMsgString.listpos = x;
3742
3743
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3744 {
3745 return qe_invalid;
3746 }
3747
3748 2550 buf[74] = '\0';
3749
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 tempMsgString.s = buf;
3750
3751
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3752 {
3753 return qe_invalid;
3754 }
3755
3756
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3757
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3758 {
3759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3760
3761
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3762 {
3763 return qe_invalid;
3764 }
3765
3766
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3767 {
3768 return qe_invalid;
3769 }
3770 2304 }
3771 else
3772 {
3773
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3774 {
3775 return qe_invalid;
3776 }
3777
3778
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3779 {
3780 return qe_invalid;
3781 }
3782 }
3783
3784
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3785
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3786 2550 }
3787 24 }
3788 else
3789 {
3790 int32_t dummy_int;
3791 word s_version;
3792 word s_cversion;
3793
3794 //section version info
3795
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&s_version,f))
3796 {
3797 return qe_invalid;
3798 }
3799
3800 663 FFCore.quest_format[vStrings] = s_version;
3801
3802
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&s_cversion,f))
3803 {
3804 return qe_invalid;
3805 }
3806
3807 //al_trace("Strings version %d\n", s_version);
3808 //section size
3809
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetl(&dummy_int,f))
3810 {
3811 return qe_invalid;
3812 }
3813
3814 //finally... section data
3815
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&temp_msg_count,f))
3816 {
3817 return qe_invalid;
3818 }
3819
3820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(temp_msg_count >= msg_strings_size)
3821 {
3822 Z_message("Reallocating string buffer...\n");
3823
3824 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3825 // return qe_nomem;
3826 delete[] MsgStrings;
3827 MsgStrings = new MsgStr[MAXMSGS];
3828 msg_strings_size = MAXMSGS;
3829 for(auto q = 0; q < msg_strings_size; ++q)
3830 {
3831 MsgStrings[q].clear();
3832 }
3833 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3834 }
3835
3836 //reset the message strings
3837
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 419 times.
663 if(s_version < 7)
3838
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3839
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 init_msgstrings(0,msg_strings_size);
3840
3841 663 int32_t string_length=(s_version<2)?73:145;
3842
3843
2/2
✓ Branch 0 taken 133817 times.
✓ Branch 1 taken 663 times.
134480 for(int32_t i=0; i<temp_msg_count; i++)
3844 {
3845
1/2
✓ Branch 0 taken 133817 times.
✗ Branch 1 not taken.
133817 init_msgstr(&tempMsgString);
3846 133817 tempMsgString.listpos = i;
3847
2/2
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 128146 times.
133817 if(s_version > 8)
3848 {
3849
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_igetl(&string_length,f))
3850 {
3851 return qe_invalid;
3852 }
3853 5671 }
3854
3855
2/4
✓ Branch 0 taken 133817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133817 times.
133817 if (string_length < 0 || string_length > 8193)
3856 {
3857 return qe_invalid;
3858 }
3859
3860
2/2
✓ Branch 0 taken 133295 times.
✓ Branch 1 taken 522 times.
133817 if (string_length > 0)
3861 {
3862
2/4
✓ Branch 0 taken 133295 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133295 times.
✗ Branch 3 not taken.
133295 if (!pfread(buf, string_length, f))
3863 {
3864 return qe_invalid;
3865 }
3866 133295 }
3867 else
3868 {
3869 522 buf[0] = 0;
3870 }
3871
3872
2/4
✓ Branch 0 taken 133817 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133817 times.
✗ Branch 3 not taken.
133817 if(!p_igetw(&tempMsgString.nextstring,f))
3873 {
3874 return qe_invalid;
3875 }
3876
3877
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 100204 times.
133817 if(s_version<2)
3878 {
3879 33613 buf[72] = '\0';
3880
1/2
✓ Branch 0 taken 33613 times.
✗ Branch 1 not taken.
33613 tempMsgString.s = buf;
3881 33613 }
3882 else
3883 {
3884 // June 2008: A bug corrupted the last 4 chars of a string.
3885 // Discard these.
3886
1/2
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
100204 if(s_version<3)
3887 {
3888 for(int32_t j=140; j<144; j++)
3889 {
3890 buf[j] = '\0';
3891 }
3892 }
3893
1/2
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
100204 if(string_length > 8192) string_length = 8192;
3894 100204 buf[string_length]='\0'; //Force-terminate
3895
1/2
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
100204 tempMsgString.s = buf;
3896
3897
2/2
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 94533 times.
100204 if ( s_version >= 6 )
3898 {
3899
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_igetl(&tempMsgString.tile,f))
3900 {
3901 return qe_invalid;
3902 }
3903 5671 }
3904 else
3905 {
3906
2/4
✓ Branch 0 taken 94533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94533 times.
✗ Branch 3 not taken.
94533 if(!p_igetw(&tempMsgString.tile,f))
3907 {
3908 return qe_invalid;
3909 }
3910 }
3911
3912
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&tempMsgString.cset,f))
3913 {
3914 return qe_invalid;
3915 }
3916
3917 byte dummy_char;
3918
3919
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3920 {
3921 return qe_invalid;
3922 }
3923
3924 100204 tempMsgString.trans=dummy_char!=0;
3925
3926
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&tempMsgString.font,f))
3927 {
3928 return qe_invalid;
3929 }
3930
3931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100204 times.
100204 if(s_version < 5)
3932 {
3933 if(!p_getc(&tempMsgString.y,f))
3934 {
3935 return qe_invalid;
3936 }
3937 }
3938 else
3939 {
3940
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_igetw(&tempMsgString.x,f))
3941 {
3942 return qe_invalid;
3943 }
3944
3945
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_igetw(&tempMsgString.y,f))
3946 {
3947 return qe_invalid;
3948 }
3949
3950
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_igetw(&tempMsgString.w,f))
3951 {
3952 return qe_invalid;
3953 }
3954
3955
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_igetw(&tempMsgString.h,f))
3956 {
3957 return qe_invalid;
3958 }
3959
3960
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&tempMsgString.hspace,f))
3961 {
3962 return qe_invalid;
3963 }
3964
3965
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&tempMsgString.vspace,f))
3966 {
3967 return qe_invalid;
3968 }
3969
3970
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&tempMsgString.stringflags,f))
3971 {
3972 return qe_invalid;
3973 }
3974 }
3975
3976
2/2
✓ Branch 0 taken 94533 times.
✓ Branch 1 taken 5671 times.
100204 if(s_version >= 7)
3977 {
3978
2/2
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 22684 times.
28355 for(int32_t q = 0; q < 4; ++q)
3979 {
3980
2/4
✓ Branch 0 taken 22684 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22684 times.
✗ Branch 3 not taken.
22684 if(!p_getc(&tempMsgString.margins[q],f))
3981 {
3982 return qe_invalid;
3983 }
3984 22684 }
3985
3986
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_igetl(&tempMsgString.portrait_tile,f))
3987 {
3988 return qe_invalid;
3989 }
3990
3991
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.portrait_cset,f))
3992 {
3993 return qe_invalid;
3994 }
3995
3996
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.portrait_x,f))
3997 {
3998 return qe_invalid;
3999 }
4000
4001
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.portrait_y,f))
4002 {
4003 return qe_invalid;
4004 }
4005
4006
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.portrait_tw,f))
4007 {
4008 return qe_invalid;
4009 }
4010
4011
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.portrait_th,f))
4012 {
4013 return qe_invalid;
4014 }
4015 5671 }
4016
4017
2/2
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 94533 times.
100204 if(s_version >= 8)
4018 {
4019
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.shadow_type,f))
4020 {
4021 return qe_invalid;
4022 }
4023
4024
2/4
✓ Branch 0 taken 5671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5671 times.
✗ Branch 3 not taken.
5671 if(!p_getc(&tempMsgString.shadow_color,f))
4025 {
4026 return qe_invalid;
4027 }
4028 5671 }
4029
4030
2/2
✓ Branch 0 taken 5362 times.
✓ Branch 1 taken 94842 times.
100204 if(s_version >= 10)
4031 {
4032
2/4
✓ Branch 0 taken 5362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5362 times.
✗ Branch 3 not taken.
5362 if(!p_getc(&tempMsgString.drawlayer,f))
4033 {
4034 return qe_invalid;
4035 }
4036 5362 }
4037
4038
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_getc(&tempMsgString.sfx,f))
4039 {
4040 return qe_invalid;
4041 }
4042
4043
1/2
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
100204 if(s_version>3)
4044 {
4045
2/4
✓ Branch 0 taken 100204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100204 times.
✗ Branch 3 not taken.
100204 if(!p_igetw(&tempMsgString.listpos,f))
4046 {
4047 return qe_invalid;
4048 }
4049 100204 }
4050 }
4051
4052
1/2
✓ Branch 0 taken 133817 times.
✗ Branch 1 not taken.
133817 MsgStrings[i].copyAll(tempMsgString);
4053 133817 }
4054 }
4055
4056
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if (!should_skip)
4057 686 msg_count=temp_msg_count;
4058
4059 687 return 0;
4060 687 }
4061
4062 687 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4063 {
4064
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4065
4066
3/4
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
693 if((Header->zelda_version < 0x192)||
4067
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 663 times.
669 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4068 {
4069 18 return 0;
4070 }
4071
4072 669 word temp_door_combo_set_count=0;
4073 DoorComboSet tempDoorComboSet;
4074 word dummy_word;
4075 int32_t dummy_long;
4076 byte padding;
4077 669 int32_t s_version = 0;
4078
4079
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 668 times.
669 if (!should_skip)
4080
2/2
✓ Branch 0 taken 171008 times.
✓ Branch 1 taken 668 times.
171676 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4081 {
4082 171008 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4083 171676 }
4084
4085
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 663 times.
669 if(Header->zelda_version > 0x192)
4086 {
4087 //section version info
4088
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
4089 {
4090 return qe_invalid;
4091 }
4092
4093 663 FFCore.quest_format[vDoors] = s_version;
4094
4095 //al_trace("Door combo sets version %d\n", dummy_word);
4096
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&dummy_word,f))
4097 {
4098 return qe_invalid;
4099 }
4100
4101 //section size
4102
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy_long,f))
4103 {
4104 return qe_invalid;
4105 }
4106 663 }
4107
4108 //finally... section data
4109
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&temp_door_combo_set_count,f))
4110 {
4111 return qe_invalid;
4112 }
4113
4114
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
669 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4115 {
4116 return qe_invalid;
4117 }
4118
4119
2/2
✓ Branch 0 taken 5486 times.
✓ Branch 1 taken 669 times.
6155 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4120 {
4121 5486 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4122
4123 //name
4124
1/2
✓ Branch 0 taken 5486 times.
✗ Branch 1 not taken.
5486 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4125 {
4126 return qe_invalid;
4127 }
4128
4129
2/2
✓ Branch 0 taken 5446 times.
✓ Branch 1 taken 40 times.
5486 if(Header->zelda_version < 0x193)
4130 {
4131
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4132 {
4133 return qe_invalid;
4134 }
4135 40 }
4136
4137 //up door
4138
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4139 {
4140
2/2
✓ Branch 0 taken 197496 times.
✓ Branch 1 taken 49374 times.
246870 for(int32_t k=0; k<4; k++)
4141 {
4142
1/2
✓ Branch 0 taken 197496 times.
✗ Branch 1 not taken.
197496 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4143 {
4144 return qe_invalid;
4145 }
4146 197496 }
4147 49374 }
4148
4149
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4150 {
4151
2/2
✓ Branch 0 taken 197496 times.
✓ Branch 1 taken 49374 times.
246870 for(int32_t k=0; k<4; k++)
4152 {
4153
1/2
✓ Branch 0 taken 197496 times.
✗ Branch 1 not taken.
197496 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4154 {
4155 return qe_invalid;
4156 }
4157 197496 }
4158 49374 }
4159
4160 //down door
4161
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4162 {
4163
2/2
✓ Branch 0 taken 197496 times.
✓ Branch 1 taken 49374 times.
246870 for(int32_t k=0; k<4; k++)
4164 {
4165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 197496 times.
197496 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4166 {
4167 return qe_invalid;
4168 }
4169 197496 }
4170 49374 }
4171
4172
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4173 {
4174
2/2
✓ Branch 0 taken 197496 times.
✓ Branch 1 taken 49374 times.
246870 for(int32_t k=0; k<4; k++)
4175 {
4176
1/2
✓ Branch 0 taken 197496 times.
✗ Branch 1 not taken.
197496 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4177 {
4178 return qe_invalid;
4179 }
4180 197496 }
4181 49374 }
4182
4183 //left door
4184
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4185 {
4186
2/2
✓ Branch 0 taken 296244 times.
✓ Branch 1 taken 49374 times.
345618 for(int32_t k=0; k<6; k++)
4187 {
4188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296244 times.
296244 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4189 {
4190 return qe_invalid;
4191 }
4192 296244 }
4193 49374 }
4194
4195
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4196 {
4197
2/2
✓ Branch 0 taken 296244 times.
✓ Branch 1 taken 49374 times.
345618 for(int32_t k=0; k<6; k++)
4198 {
4199
1/2
✓ Branch 0 taken 296244 times.
✗ Branch 1 not taken.
296244 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4200 {
4201 return qe_invalid;
4202 }
4203 296244 }
4204 49374 }
4205
4206 //right door
4207
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4208 {
4209
2/2
✓ Branch 0 taken 296244 times.
✓ Branch 1 taken 49374 times.
345618 for(int32_t k=0; k<6; k++)
4210 {
4211
1/2
✓ Branch 0 taken 296244 times.
✗ Branch 1 not taken.
296244 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4212 {
4213 return qe_invalid;
4214 }
4215 296244 }
4216 49374 }
4217
4218
2/2
✓ Branch 0 taken 49374 times.
✓ Branch 1 taken 5486 times.
54860 for(int32_t j=0; j<9; j++)
4219 {
4220
2/2
✓ Branch 0 taken 296244 times.
✓ Branch 1 taken 49374 times.
345618 for(int32_t k=0; k<6; k++)
4221 {
4222
1/2
✓ Branch 0 taken 296244 times.
✗ Branch 1 not taken.
296244 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4223 {
4224 return qe_invalid;
4225 }
4226 296244 }
4227 49374 }
4228
4229 //up bomb rubble
4230
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 5486 times.
16458 for(int32_t j=0; j<2; j++)
4231 {
4232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10972 times.
10972 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4233 {
4234 return qe_invalid;
4235 }
4236 10972 }
4237
4238
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 5486 times.
16458 for(int32_t j=0; j<2; j++)
4239 {
4240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10972 times.
10972 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4241 {
4242 return qe_invalid;
4243 }
4244 10972 }
4245
4246 //down bomb rubble
4247
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 5486 times.
16458 for(int32_t j=0; j<2; j++)
4248 {
4249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10972 times.
10972 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4250 {
4251 return qe_invalid;
4252 }
4253 10972 }
4254
4255
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 5486 times.
16458 for(int32_t j=0; j<2; j++)
4256 {
4257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10972 times.
10972 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4258 {
4259 return qe_invalid;
4260 }
4261 10972 }
4262
4263 //left bomb rubble
4264
2/2
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 5486 times.
21944 for(int32_t j=0; j<3; j++)
4265 {
4266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16458 times.
16458 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4267 {
4268 return qe_invalid;
4269 }
4270 16458 }
4271
4272
2/2
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 5486 times.
21944 for(int32_t j=0; j<3; j++)
4273 {
4274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16458 times.
16458 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4275 {
4276 return qe_invalid;
4277 }
4278 16458 }
4279
4280
2/2
✓ Branch 0 taken 5446 times.
✓ Branch 1 taken 40 times.
5486 if(Header->zelda_version < 0x193)
4281 {
4282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4283 {
4284 return qe_invalid;
4285 }
4286
4287 40 }
4288
4289 //right bomb rubble
4290
2/2
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 5486 times.
21944 for(int32_t j=0; j<3; j++)
4291 {
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16458 times.
16458 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4293 {
4294 return qe_invalid;
4295 }
4296 16458 }
4297
4298
2/2
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 5486 times.
21944 for(int32_t j=0; j<3; j++)
4299 {
4300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16458 times.
16458 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4301 {
4302 return qe_invalid;
4303 }
4304 16458 }
4305
4306
2/2
✓ Branch 0 taken 5446 times.
✓ Branch 1 taken 40 times.
5486 if(Header->zelda_version < 0x193)
4307 {
4308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4309 {
4310 return qe_invalid;
4311 }
4312 40 }
4313
4314 //walkthrough stuff
4315
2/2
✓ Branch 0 taken 21944 times.
✓ Branch 1 taken 5486 times.
27430 for(int32_t j=0; j<4; j++)
4316 {
4317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21944 times.
21944 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4318 {
4319 return qe_invalid;
4320 }
4321 21944 }
4322
4323
2/2
✓ Branch 0 taken 21944 times.
✓ Branch 1 taken 5486 times.
27430 for(int32_t j=0; j<4; j++)
4324 {
4325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21944 times.
21944 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4326 {
4327 return qe_invalid;
4328 }
4329 21944 }
4330
4331 //flags
4332
2/2
✓ Branch 0 taken 10972 times.
✓ Branch 1 taken 5486 times.
16458 for(int32_t j=0; j<2; j++)
4333 {
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10972 times.
10972 if(!p_getc(&tempDoorComboSet.flags[j],f))
4335 {
4336 return qe_invalid;
4337 }
4338 10972 }
4339
4340
2/2
✓ Branch 0 taken 5446 times.
✓ Branch 1 taken 40 times.
5486 if(Header->zelda_version < 0x193)
4341 {
4342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4343 {
4344 return qe_invalid;
4345 }
4346 40 }
4347
4348
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5472 times.
5486 if (!should_skip)
4349 5472 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4350 5486 }
4351
4352
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 668 times.
669 if (!should_skip)
4353 668 door_combo_set_count=temp_door_combo_set_count;
4354
4355 669 return 0;
4356 687 }
4357
4358 5 int32_t count_dmaps()
4359 {
4360 5 int32_t i=MAXDMAPS-1;
4361 5 bool found=false;
4362
4363
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 5 times.
5 while(i>=0 && !found)
4364 {
4365
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
15 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4366
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4367
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4368 10 found=true;
4369
4370
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10 times.
50 for(int32_t j=0; j<8; j++)
4371 {
4372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(DMaps[i].grid[j]!=0)
4373
4374 found=true;
4375 40 }
4376
4377
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 5 times.
10 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4378 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4379 15 found=true;
4380
4381
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
15 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4382
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4383
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4384
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4385 10 found=true;
4386
4387 if(!found)
4388 {
4389 i--;
4390 }
4391 }
4392
4393 5 return i+1;
4394 }
4395
4396
4397 5 int32_t count_shops(miscQdata *Misc)
4398 {
4399 5 int32_t i=NUM_SHOPS-1,j;
4400 5 bool found=false;
4401
4402
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 5 times.
1225 while(i>=0 && !found)
4403 {
4404 1220 j=2;
4405
4406
4/4
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 3656 times.
✓ Branch 2 taken 3652 times.
✓ Branch 3 taken 1220 times.
4872 while(j>=0 && !found)
4407 {
4408
3/4
✓ Branch 0 taken 3648 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3648 times.
3652 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4409 {
4410 4 found=true;
4411 4 }
4412 else
4413 {
4414 3648 j--;
4415 }
4416 }
4417
4418
1/2
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
1220 if(Misc->shop[i].name[0]!=0)
4419 {
4420 found=true;
4421 }
4422
4423
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1216 times.
1220 if(!found)
4424 {
4425 1216 i--;
4426 1216 }
4427 }
4428
4429 5 return i+1;
4430 }
4431
4432 5 int32_t count_infos(miscQdata *Misc)
4433 {
4434 5 int32_t i=255,j;
4435 5 bool found=false;
4436
4437
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 5 times.
1225 while(i>=0 && !found)
4438 {
4439 1220 j=2;
4440
4441
4/4
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 3656 times.
✓ Branch 2 taken 3652 times.
✓ Branch 3 taken 1220 times.
4872 while(j>=0 && !found)
4442 {
4443
4/4
✓ Branch 0 taken 3651 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3648 times.
3652 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4444 {
4445 4 found=true;
4446 4 }
4447 else
4448 {
4449 3648 j--;
4450 }
4451 }
4452
4453
1/2
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
1220 if(Misc->info[i].name[0]!=0)
4454 {
4455 found=true;
4456 }
4457
4458
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1216 times.
1220 if(!found)
4459 {
4460 1216 i--;
4461 1216 }
4462 }
4463
4464 5 return i+1;
4465 }
4466
4467 5 int32_t count_warprings(miscQdata *Misc)
4468 {
4469 5 int32_t i=15,j;
4470 5 bool found=false;
4471
4472
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 5 times.
33 while(i>=0 && !found)
4473 {
4474 28 j=7;
4475
4476
4/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 201 times.
✓ Branch 3 taken 28 times.
229 while(j>=0 && !found)
4477 {
4478
4/4
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 196 times.
201 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4479 {
4480 5 found=true;
4481 5 }
4482 else
4483 {
4484 196 j--;
4485 }
4486 }
4487
4488
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 23 times.
28 if(!found)
4489 {
4490 23 i--;
4491 23 }
4492 }
4493
4494 5 return i+1;
4495 }
4496
4497 5 int32_t count_palcycles(miscQdata *Misc)
4498 {
4499 5 int32_t i=255,j;
4500 5 bool found=false;
4501
4502
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1164 times.
✓ Branch 2 taken 1161 times.
✓ Branch 3 taken 5 times.
1166 while(i>=0 && !found)
4503 {
4504 1161 j=2;
4505
4506
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 3480 times.
✓ Branch 2 taken 3477 times.
✓ Branch 3 taken 1161 times.
4638 while(j>=0 && !found)
4507 {
4508
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3474 times.
3477 if(Misc->cycles[i][j].count!=0)
4509 {
4510 3 found=true;
4511 3 }
4512 else
4513 {
4514 3474 j--;
4515 }
4516 }
4517
4518
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1158 times.
1161 if(!found)
4519 {
4520 1158 i--;
4521 1158 }
4522 }
4523
4524 5 return i+1;
4525 }
4526
4527 1334583 void clear_screen(mapscr *temp_scr)
4528 {
4529 1334583 temp_scr->zero_memory();
4530 1334583 }
4531
4532 // NOTE: when modifying this, you need to also update:
4533 // readonedmap, readdmaps, and FFScript::read_dmaps
4534 // (and their associated write functions)
4535 3759 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4536 {
4537
2/2
✓ Branch 0 taken 3735 times.
✓ Branch 1 taken 24 times.
3759 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4538
4539 3759 word dmapstoread=0;
4540 3759 dmap tempDMap;
4541
4542 int32_t dummy;
4543 3759 word s_version=0, s_cversion=0;
4544 byte padding;
4545
4546 char legacy_title[22];
4547
4548
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 686 times.
3759 if (!should_skip)
4549
2/2
✓ Branch 0 taken 351232 times.
✓ Branch 1 taken 686 times.
351918 for(int32_t i=0; i<max_dmaps; i++)
4550 {
4551
1/2
✓ Branch 0 taken 351232 times.
✗ Branch 1 not taken.
351232 DMaps[start_dmap + i].clear();
4552 351232 sprintf(legacy_title," ");
4553 351232 sprintf(DMaps[start_dmap+i].intro," ");
4554 351232 DMaps[start_dmap+i].type |= dmCAVE;
4555 351918 }
4556
4557
4/4
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 24 times.
3759 if(!Header || Header->zelda_version > 0x192)
4558 {
4559 //section version info
4560
3/4
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
3735 if(!p_igetw(&s_version,f))
4561 {
4562 return qe_invalid;
4563 }
4564
4565 663 FFCore.quest_format[vDMaps] = s_version;
4566
4567 //al_trace("DMaps version %d\n", s_version);
4568
4569
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&s_cversion,f))
4570 {
4571 return qe_invalid;
4572 }
4573
4574 //section size
4575
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetl(&dummy,f))
4576 {
4577 return qe_invalid;
4578 }
4579
4580 //finally... section data
4581
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&dmapstoread,f))
4582 {
4583 return qe_invalid;
4584 }
4585 663 }
4586 else
4587 {
4588
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4589
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4590 {
4591 18 dmapstoread=32;
4592 18 }
4593
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4594 {
4595 6 dmapstoread=OLDMAXDMAPS;
4596 6 }
4597 else
4598 {
4599 dmapstoread=MAXDMAPS;
4600 }
4601 }
4602
4603
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 604 times.
687 dmapstoread=zc_min(dmapstoread, max_dmaps);
4604
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 604 times.
687 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4605
4606
2/2
✓ Branch 0 taken 326464 times.
✓ Branch 1 taken 687 times.
327151 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4607 {
4608
1/2
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
326464 tempDMap.clear();
4609 326464 sprintf(legacy_title," ");
4610 326464 sprintf(tempDMap.intro," ");
4611
4612
2/4
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326464 times.
✗ Branch 3 not taken.
326464 if(!p_getc(&tempDMap.map,f))
4613 {
4614 return qe_invalid;
4615 }
4616
4617
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 309248 times.
326464 if(s_version <= 4)
4618 {
4619 byte tempbyte;
4620
4621
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4622 {
4623 return qe_invalid;
4624 }
4625
4626 17216 tempDMap.level=(word)tempbyte;
4627 17216 }
4628 else
4629 {
4630
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!p_igetw(&tempDMap.level,f))
4631 {
4632 return qe_invalid;
4633 }
4634 }
4635
4636
2/4
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326464 times.
✗ Branch 3 not taken.
326464 if(!p_getc(&tempDMap.xoff,f))
4637 {
4638 return qe_invalid;
4639 }
4640
4641
2/4
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326464 times.
✗ Branch 3 not taken.
326464 if(!p_getc(&tempDMap.compass,f))
4642 {
4643 return qe_invalid;
4644 }
4645
4646
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 17216 times.
326464 if(s_version > 8) // February 2009
4647 {
4648
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!p_igetw(&tempDMap.color,f))
4649 {
4650 return qe_invalid;
4651 }
4652 309248 }
4653 else
4654 {
4655 byte tempbyte;
4656
4657
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4658 {
4659 return qe_invalid;
4660 }
4661
4662 17216 tempDMap.color = (word)tempbyte;
4663 }
4664
4665
2/4
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326464 times.
✗ Branch 3 not taken.
326464 if(!p_getc(&tempDMap.midi,f))
4666 {
4667 return qe_invalid;
4668 }
4669
4670
2/4
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326464 times.
✗ Branch 3 not taken.
326464 if(!p_getc(&tempDMap.cont,f))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
2/4
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326464 times.
✗ Branch 3 not taken.
326464 if(!p_getc(&tempDMap.type,f))
4676 {
4677 return qe_invalid;
4678 }
4679
4680
4/4
✓ Branch 0 taken 5484 times.
✓ Branch 1 taken 320980 times.
✓ Branch 2 taken 5440 times.
✓ Branch 3 taken 44 times.
331948 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4681
1/2
✓ Branch 0 taken 5484 times.
✗ Branch 1 not taken.
5484 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4682 5440 tempDMap.xoff = 0;
4683
4684
2/2
✓ Branch 0 taken 326464 times.
✓ Branch 1 taken 2611712 times.
2938176 for(int32_t j=0; j<8; j++)
4685 {
4686
2/4
✓ Branch 0 taken 2611712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2611712 times.
✗ Branch 3 not taken.
2611712 if(!p_getc(&tempDMap.grid[j],f))
4687 {
4688 return qe_invalid;
4689 }
4690 2611712 }
4691
4692
5/6
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 324352 times.
326464 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4693 {
4694
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4695 {
4696 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4697 127 }
4698
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4699
4700
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4701 {
4702
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4703
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4704 18 }
4705
4706 //forgotten -DD
4707
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4708 {
4709 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4710 439 }
4711 576 }
4712 else
4713 {
4714
3/4
✓ Branch 0 taken 325888 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
324352 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4715 {
4716 return qe_invalid;
4717 }
4718
4719
2/2
✓ Branch 0 taken 120576 times.
✓ Branch 1 taken 205312 times.
325888 if(s_version<20)
4720 {
4721
2/4
✓ Branch 0 taken 120576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120576 times.
✗ Branch 3 not taken.
120576 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4722 {
4723 return qe_invalid;
4724 }
4725
1/2
✓ Branch 0 taken 120576 times.
✗ Branch 1 not taken.
120576 tempDMap.title.assign(legacy_title);
4726 120576 }
4727 else
4728 {
4729
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if (!p_getwstr(&tempDMap.title, f))
4730 {
4731 return qe_invalid;
4732 }
4733 }
4734
4735
2/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
325888 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4736 {
4737 return qe_invalid;
4738 }
4739
4740
5/8
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 324352 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
325888 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4741 {
4742 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4743 DMaps[i] = tempDMap;
4744
4745 continue;
4746 }
4747
4748
3/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 324352 times.
325888 if(Header && (Header->zelda_version < 0x193))
4749 {
4750
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4751 {
4752 return qe_invalid;
4753 }
4754 1536 }
4755
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111360 times.
325888 if ( s_version >= 11 )
4756 {
4757
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4758 {
4759 return qe_invalid;
4760 }
4761 214528 }
4762 else
4763 {
4764
2/4
✓ Branch 0 taken 111360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111360 times.
✗ Branch 3 not taken.
111360 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4765 {
4766 return qe_invalid;
4767 }
4768 }
4769
4770
2/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
325888 if(!p_getc(&tempDMap.minimap_1_cset,f))
4771 {
4772 return qe_invalid;
4773 }
4774
4775
3/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 324352 times.
325888 if(Header && (Header->zelda_version < 0x193))
4776 {
4777
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4778 {
4779 return qe_invalid;
4780 }
4781 1536 }
4782
4783
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111360 times.
325888 if ( s_version >= 11 )
4784 {
4785
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4786 {
4787 return qe_invalid;
4788 }
4789 214528 }
4790 else
4791 {
4792
2/4
✓ Branch 0 taken 111360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111360 times.
✗ Branch 3 not taken.
111360 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4793 {
4794 return qe_invalid;
4795 }
4796 }
4797
2/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
325888 if(!p_getc(&tempDMap.minimap_2_cset,f))
4798 {
4799 return qe_invalid;
4800 }
4801
4802
3/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 324352 times.
325888 if(Header && (Header->zelda_version < 0x193))
4803 {
4804
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4805 {
4806 return qe_invalid;
4807 }
4808 1536 }
4809
4810
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111360 times.
325888 if ( s_version >= 11 )
4811 {
4812
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4813 {
4814 return qe_invalid;
4815 }
4816 214528 }
4817 else
4818 {
4819
2/4
✓ Branch 0 taken 111360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111360 times.
✗ Branch 3 not taken.
111360 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4820 {
4821 return qe_invalid;
4822 }
4823 }
4824
4825
2/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
325888 if(!p_getc(&tempDMap.largemap_1_cset,f))
4826 {
4827 return qe_invalid;
4828 }
4829
4830
3/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 324352 times.
325888 if(Header && (Header->zelda_version < 0x193))
4831 {
4832
4833
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4834 {
4835 return qe_invalid;
4836 }
4837 1536 }
4838
4839
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111360 times.
325888 if ( s_version >= 11 )
4840 {
4841
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4842 {
4843 return qe_invalid;
4844 }
4845 214528 }
4846 else
4847 {
4848
2/4
✓ Branch 0 taken 111360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111360 times.
✗ Branch 3 not taken.
111360 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4849 {
4850 return qe_invalid;
4851 }
4852 }
4853
2/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
325888 if(!p_getc(&tempDMap.largemap_2_cset,f))
4854 {
4855 return qe_invalid;
4856 }
4857
4858
2/4
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325888 times.
✗ Branch 3 not taken.
325888 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4859 {
4860 return qe_invalid;
4861 }
4862 }
4863
4864
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 17216 times.
326464 if(s_version>1)
4865 {
4866
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!p_getc(&tempDMap.tmusictrack,f))
4867 {
4868 return qe_invalid;
4869 }
4870
4871
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!p_getc(&tempDMap.active_subscreen,f))
4872 {
4873 return qe_invalid;
4874 }
4875
4876
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!p_getc(&tempDMap.passive_subscreen,f))
4877 {
4878 return qe_invalid;
4879 }
4880 309248 }
4881
4882
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 17216 times.
326464 if(s_version>2)
4883 {
4884 byte di[32];
4885
4886
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!pfread(&di, 32, f)) return qe_invalid;
4887
4888
2/2
✓ Branch 0 taken 79167488 times.
✓ Branch 1 taken 309248 times.
79476736 for(int32_t j=0; j<MAXITEMS; j++)
4889 {
4890
2/2
✓ Branch 0 taken 9038 times.
✓ Branch 1 taken 79158450 times.
79167488 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4891 79158450 else tempDMap.disableditems[j]=0;
4892 79167488 }
4893 309248 }
4894
4895
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 17216 times.
326464 if(s_version >= 6)
4896 {
4897
2/4
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309248 times.
✗ Branch 3 not taken.
309248 if(!p_igetl(&tempDMap.flags,f))
4898 {
4899 return qe_invalid;
4900 }
4901 309248 }
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4903 {
4904 char temp;
4905
4906 if(!p_getc(&temp,f))
4907 {
4908 return qe_invalid;
4909 }
4910
4911 tempDMap.flags = temp;
4912 }
4913
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4914 {
4915 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4916 8992 }
4917 else
4918 8224 tempDMap.flags=0;
4919
4920
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 17216 times.
326464 if(s_version<7)
4921 {
4922
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4923 6146 tempDMap.flags|= dmfVIEWMAP;
4924 17216 }
4925
4926
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 17216 times.
326464 if(s_version<8)
4927 {
4928
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 942 times.
✓ Branch 3 taken 8050 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4929 {
4930 8050 tempDMap.type &= ~dmDNGN;
4931 8050 tempDMap.type |= dmCAVE;
4932 8050 }
4933
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4934 {
4935 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4936 2332 }
4937 17216 }
4938
4939
7/8
✓ Branch 0 taken 326464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 324352 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 324352 times.
326464 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4940 325888 && (Header->zelda_version < 0x193))
4941 {
4942
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4943 {
4944 return qe_invalid;
4945 }
4946 1536 }
4947
4948
2/2
✓ Branch 0 taken 111936 times.
✓ Branch 1 taken 214528 times.
326464 if(s_version >= 10)
4949 {
4950
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_getc(&tempDMap.sideview,f))
4951 {
4952 return qe_invalid;
4953 }
4954 214528 }
4955
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if(s_version < 10) tempDMap.sideview = 0;
4956
4957 //Dmap Scripts
4958
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if(s_version >= 12)
4959 {
4960
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetw(&tempDMap.script,f))
4961 {
4962 return qe_invalid;
4963 }
4964
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; q++ )
4965 {
4966
2/4
✓ Branch 0 taken 1716224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1716224 times.
✗ Branch 3 not taken.
1716224 if(!p_igetl(&tempDMap.initD[q],f))
4967 {
4968 return qe_invalid;
4969 }
4970 1716224 }
4971 214528 }
4972
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if ( s_version < 12 )
4973 {
4974 111936 tempDMap.script = 0;
4975
2/2
✓ Branch 0 taken 895488 times.
✓ Branch 1 taken 111936 times.
1007424 for ( int32_t q = 0; q < 8; q++ )
4976 {
4977 895488 tempDMap.initD[q] = 0;
4978 895488 }
4979 111936 }
4980
4981
2/2
✓ Branch 0 taken 111936 times.
✓ Branch 1 taken 214528 times.
326464 if(s_version >= 13)
4982 {
4983
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; q++ )
4984 {
4985
2/2
✓ Branch 0 taken 111554560 times.
✓ Branch 1 taken 1716224 times.
113270784 for ( int32_t w = 0; w < 65; w++ )
4986 {
4987
2/4
✓ Branch 0 taken 111554560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111554560 times.
✗ Branch 3 not taken.
111554560 if(!p_getc(&tempDMap.initD_label[q][w],f))
4988 {
4989 return qe_invalid;
4990 }
4991 111554560 }
4992 1716224 }
4993 214528 }
4994
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if ( s_version < 13 )
4995 {
4996 111936 tempDMap.script = 0;
4997
2/2
✓ Branch 0 taken 895488 times.
✓ Branch 1 taken 111936 times.
1007424 for ( int32_t q = 0; q < 8; q++ )
4998 {
4999
2/2
✓ Branch 0 taken 58206720 times.
✓ Branch 1 taken 895488 times.
59102208 for ( int32_t w = 0; w < 65; w++ )
5000 58206720 tempDMap.initD_label[q][w] = 0;
5001 895488 }
5002 111936 }
5003
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if(s_version >= 14)
5004 {
5005
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetw(&tempDMap.active_sub_script,f))
5006 {
5007 return qe_invalid;
5008 }
5009
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetw(&tempDMap.passive_sub_script,f))
5010 {
5011 return qe_invalid;
5012 }
5013
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; ++q )
5014 {
5015
2/4
✓ Branch 0 taken 1716224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1716224 times.
✗ Branch 3 not taken.
1716224 if(!p_igetl(&tempDMap.sub_initD[q],f))
5016 {
5017 return qe_invalid;
5018 }
5019 1716224 }
5020
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for(int32_t q = 0; q < 8; ++q)
5021 {
5022
2/2
✓ Branch 0 taken 111554560 times.
✓ Branch 1 taken 1716224 times.
113270784 for ( int32_t w = 0; w < 65; ++w )
5023 {
5024
2/4
✓ Branch 0 taken 111554560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111554560 times.
✗ Branch 3 not taken.
111554560 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5025 {
5026 return qe_invalid;
5027 }
5028 111554560 }
5029 1716224 }
5030 214528 }
5031 else
5032 {
5033 111936 tempDMap.active_sub_script = 0;
5034 111936 tempDMap.passive_sub_script = 0;
5035
2/2
✓ Branch 0 taken 895488 times.
✓ Branch 1 taken 111936 times.
1007424 for(int32_t q = 0; q < 8; ++q)
5036 {
5037 895488 tempDMap.sub_initD[q] = 0;
5038
2/2
✓ Branch 0 taken 58206720 times.
✓ Branch 1 taken 895488 times.
59102208 for(int32_t w = 0; w < 65; ++w)
5039 58206720 tempDMap.sub_initD_label[q][w] = 0;
5040 895488 }
5041 }
5042
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if(s_version >= 15)
5043 {
5044
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetw(&tempDMap.onmap_script,f))
5045 {
5046 return qe_invalid;
5047 }
5048
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; ++q )
5049 {
5050
2/4
✓ Branch 0 taken 1716224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1716224 times.
✗ Branch 3 not taken.
1716224 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5051 {
5052 return qe_invalid;
5053 }
5054 1716224 }
5055
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for(int32_t q = 0; q < 8; ++q)
5056 {
5057
2/2
✓ Branch 0 taken 111554560 times.
✓ Branch 1 taken 1716224 times.
113270784 for ( int32_t w = 0; w < 65; ++w )
5058 {
5059
2/4
✓ Branch 0 taken 111554560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111554560 times.
✗ Branch 3 not taken.
111554560 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5060 {
5061 return qe_invalid;
5062 }
5063 111554560 }
5064 1716224 }
5065 214528 }
5066 else
5067 {
5068 111936 tempDMap.onmap_script = 0;
5069
2/2
✓ Branch 0 taken 895488 times.
✓ Branch 1 taken 111936 times.
1007424 for(int32_t q = 0; q < 8; ++q)
5070 {
5071 895488 tempDMap.onmap_initD[q] = 0;
5072
2/2
✓ Branch 0 taken 58206720 times.
✓ Branch 1 taken 895488 times.
59102208 for(int32_t w = 0; w < 65; ++w)
5073 {
5074 58206720 tempDMap.onmap_initD_label[q][w] = 0;
5075 58206720 }
5076 895488 }
5077 }
5078
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 111936 times.
326464 if(s_version >= 16)
5079 {
5080
2/4
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
214528 if(!p_igetw(&tempDMap.mirrorDMap,f))
5081 {
5082 return qe_invalid;
5083 }
5084 214528 }
5085 else
5086 {
5087 111936 tempDMap.mirrorDMap = -1;
5088 }
5089
5090
2/2
✓ Branch 0 taken 121152 times.
✓ Branch 1 taken 205312 times.
326464 if (s_version >= 17)
5091 {
5092 // Reserved for z3.
5093 205312 }
5094
5095 // Enhanced music loop points
5096
2/2
✓ Branch 0 taken 205312 times.
✓ Branch 1 taken 121152 times.
326464 if (s_version >= 18)
5097 {
5098
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5099 {
5100 return qe_invalid;
5101 }
5102
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5103 {
5104 return qe_invalid;
5105 }
5106
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5107 {
5108 return qe_invalid;
5109 }
5110
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5111 {
5112 return qe_invalid;
5113 }
5114 205312 }
5115 else
5116 {
5117 121152 tempDMap.tmusic_loop_start = 0;
5118 121152 tempDMap.tmusic_loop_end = 0;
5119 121152 tempDMap.tmusic_xfade_in = 0;
5120 121152 tempDMap.tmusic_xfade_out = 0;
5121 }
5122
5123
2/2
✓ Branch 0 taken 205312 times.
✓ Branch 1 taken 121152 times.
326464 if(s_version >= 19)
5124
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if(!p_getc(&tempDMap.overlay_subscreen, f))
5125 return qe_invalid;
5126
5127
2/2
✓ Branch 0 taken 205312 times.
✓ Branch 1 taken 121152 times.
326464 if (s_version >= 20)
5128 {
5129
2/4
✓ Branch 0 taken 205312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205312 times.
✗ Branch 3 not taken.
205312 if (!p_igetl(&tempDMap.intro_string_id, f))
5130 return qe_invalid;
5131 205312 }
5132 else
5133 121152 tempDMap.intro_string_id = 0;
5134
5135 // Reserved for z3.
5136
2/2
✓ Branch 0 taken 121152 times.
✓ Branch 1 taken 205312 times.
326464 if(s_version >= 21)
5137 {
5138
2/2
✓ Branch 0 taken 1642496 times.
✓ Branch 1 taken 205312 times.
1847808 for(int32_t j=0; j<8; j++)
5139 {
5140
2/2
✓ Branch 0 taken 13139968 times.
✓ Branch 1 taken 1642496 times.
14782464 for(int32_t k=0; k<8; k++)
5141 {
5142 char c;
5143
2/4
✓ Branch 0 taken 13139968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13139968 times.
✗ Branch 3 not taken.
13139968 if(!p_getc(&c,f))
5144 {
5145 return qe_invalid;
5146 }
5147 13139968 }
5148 1642496 }
5149 205312 }
5150
5151
2/2
✓ Branch 0 taken 326208 times.
✓ Branch 1 taken 256 times.
326464 if (!should_skip)
5152 {
5153
1/2
✓ Branch 0 taken 326208 times.
✗ Branch 1 not taken.
326208 if(loading_tileset_flags & TILESET_CLEARMAPS)
5154 tempDMap.map = 0;
5155
1/2
✓ Branch 0 taken 326208 times.
✗ Branch 1 not taken.
326208 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5156 {
5157 tempDMap.script = 0;
5158 for(int q = 0; q < 8; ++q)
5159 tempDMap.initD[q] = 0;
5160 }
5161
1/2
✓ Branch 0 taken 326208 times.
✗ Branch 1 not taken.
326208 DMaps[i] = tempDMap;
5162 326208 }
5163 326464 }
5164
5165 687 return 0;
5166 6831 }
5167
5168 604 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5169 {
5170 //these are here to bypass compiler warnings about unused arguments
5171 604 Header=Header;
5172
5173 miscQdata temp_misc;
5174 604 word s_version=0, s_cversion=0;
5175 604 int32_t tempsize=0;
5176 word dummyw;
5177
5178 604 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5179
5180 //section version info
5181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_igetw(&s_version,f))
5182 {
5183 return qe_invalid;
5184 }
5185
5186 604 FFCore.quest_format[vColours] = s_version;
5187
5188 604 al_trace("Misc Colours section version: %d\n", s_version);
5189
5190 //al_trace("Misc. colors version %d\n", s_version);
5191
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
5192 {
5193 return qe_invalid;
5194 }
5195
5196
5197 //section size
5198
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&tempsize,f))
5199 {
5200 return qe_invalid;
5201 }
5202
5203 //finally... section data
5204 604 readsize=0;
5205
5206
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.text,f))
5207 {
5208 return qe_invalid;
5209 }
5210
5211
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.caption,f))
5212 {
5213 return qe_invalid;
5214 }
5215
5216
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.overw_bg,f))
5217 {
5218 return qe_invalid;
5219 }
5220
5221
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5222 {
5223 return qe_invalid;
5224 }
5225
5226
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5227 {
5228 return qe_invalid;
5229 }
5230
5231
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.cave_fg,f))
5232 {
5233 return qe_invalid;
5234 }
5235
5236
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.bs_dk,f))
5237 {
5238 return qe_invalid;
5239 }
5240
5241
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.bs_goal,f))
5242 {
5243 return qe_invalid;
5244 }
5245
5246
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.compass_lt,f))
5247 {
5248 return qe_invalid;
5249 }
5250
5251
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.compass_dk,f))
5252 {
5253 return qe_invalid;
5254 }
5255
5256
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5257 {
5258 return qe_invalid;
5259 }
5260
5261
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.triframe_color,f))
5262 {
5263 return qe_invalid;
5264 }
5265
5266
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.hero_dot,f))
5267 {
5268 return qe_invalid;
5269 }
5270
5271
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5272 {
5273 return qe_invalid;
5274 }
5275
5276
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5277 {
5278 return qe_invalid;
5279 }
5280
5281
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5282 {
5283 return qe_invalid;
5284 }
5285
5286
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5287 {
5288 return qe_invalid;
5289 }
5290
5291
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5292 {
5293 return qe_invalid;
5294 }
5295
5296
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5297 {
5298 return qe_invalid;
5299 }
5300
5301
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5302 {
5303 return qe_invalid;
5304 }
5305
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if(s_version < 4)
5306 {
5307
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&dummyw,f))
5308 return qe_invalid;
5309 185 temp_misc.colors.triforce_tile = dummyw;
5310
5311
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&dummyw,f))
5312 return qe_invalid;
5313 185 temp_misc.colors.triframe_tile = dummyw;
5314
5315
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&dummyw,f))
5316 return qe_invalid;
5317 185 temp_misc.colors.overworld_map_tile = dummyw;
5318
5319
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&dummyw,f))
5320 return qe_invalid;
5321 185 temp_misc.colors.dungeon_map_tile = dummyw;
5322
5323
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&dummyw,f))
5324 return qe_invalid;
5325 185 temp_misc.colors.blueframe_tile = dummyw;
5326
5327
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&dummyw,f))
5328 return qe_invalid;
5329 185 temp_misc.colors.HCpieces_tile = dummyw;
5330 185 }
5331
5332
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5333 {
5334 return qe_invalid;
5335 }
5336
5337
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5338 {
5339 return qe_invalid;
5340 }
5341
5342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(s_version < 2)
5343 {
5344 temp_misc.colors.msgtext = 0x01;
5345 }
5346 else
5347 {
5348
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_getc(&temp_misc.colors.msgtext, f))
5349 {
5350 return qe_invalid;
5351 }
5352 }
5353
5354
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if ( s_version >= 3 ) //expanded tile pages to 825
5355 {
5356
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5357 {
5358 return qe_invalid;
5359 }
5360
5361
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5362 {
5363 return qe_invalid;
5364 }
5365
5366
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5367 {
5368 return qe_invalid;
5369 }
5370
5371
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5372 {
5373 return qe_invalid;
5374 }
5375
5376
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5377 {
5378 return qe_invalid;
5379 }
5380
5381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5382 {
5383 return qe_invalid;
5384 }
5385 419 }
5386
5387 604 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5388
5389 604 return 0;
5390 604 }
5391
5392 604 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5393 {
5394 miscQdata temp_misc;
5395 604 word s_version=0, s_cversion=0;
5396 byte icons;
5397 604 int32_t tempsize=0;
5398
5399 604 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5400
5401 //section version info
5402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_igetw(&s_version,f))
5403 {
5404 return qe_invalid;
5405 }
5406
5407 604 FFCore.quest_format[vIcons] = s_version;
5408
5409 //al_trace("Game icons version %d\n", s_version);
5410
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
5411 {
5412 return qe_invalid;
5413 }
5414
5415
5416 //section size
5417
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&tempsize,f))
5418 {
5419 return qe_invalid;
5420 }
5421
5422 //finally... section data
5423 604 readsize=0;
5424
5425 604 icons=4;
5426
5427
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if ( s_version >= 10 )
5428 {
5429
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<icons; i++)
5430 {
5431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_igetl(&temp_misc.icons[i],f))
5432 {
5433 return qe_invalid;
5434 }
5435 1676 }
5436 419 }
5437 else
5438 {
5439
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<icons; i++)
5440 {
5441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(!p_igetw(&temp_misc.icons[i],f))
5442 {
5443 return qe_invalid;
5444 }
5445 740 }
5446 }
5447
5448 604 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5449
5450 604 return 0;
5451 604 }
5452
5453 687 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5454 {
5455
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5456
5457 687 word maxinfos=256;
5458 687 word maxshops=256;
5459 687 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5460 687 word ponds=16, pondsize=72, expansionsize=98*2;
5461 byte tempbyte, padding;
5462 miscQdata temp_misc;
5463 687 word s_version=0, s_cversion=0;
5464 word swaptmp;
5465 687 int32_t tempsize=0;
5466
5467 687 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5468
5469
2/2
✓ Branch 0 taken 175872 times.
✓ Branch 1 taken 687 times.
176559 for(int32_t i=0; i<maxshops; ++i)
5470 {
5471 175872 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5472 175872 }
5473
5474
2/2
✓ Branch 0 taken 175872 times.
✓ Branch 1 taken 687 times.
176559 for(int32_t i=0; i<maxinfos; ++i)
5475 {
5476 175872 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5477 175872 }
5478
5479
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(Header->zelda_version > 0x192)
5480 {
5481 //section version info
5482
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
5483 {
5484 return qe_invalid;
5485 }
5486
5487 663 FFCore.quest_format[vMisc] = s_version;
5488
5489 //al_trace("Misc. data version %d\n", s_version);
5490
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_cversion,f))
5491 {
5492 return qe_invalid;
5493 }
5494
5495
5496 //section size
5497
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&tempsize,f))
5498 {
5499 return qe_invalid;
5500 }
5501 663 }
5502
5503 //finally... section data
5504 687 readsize=0;
5505
5506 //shops
5507
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(Header->zelda_version > 0x192)
5508 {
5509
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&shops,f))
5510 {
5511 return qe_invalid;
5512 }
5513 663 }
5514
5515
2/4
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 687 times.
687 if (!(shops >= 0 && shops <= NUM_SHOPS))
5516 {
5517 return qe_invalid;
5518 }
5519
5520
2/2
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 687 times.
10610 for(int32_t i=0; i<shops; i++)
5521 {
5522
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 8723 times.
9923 if(s_version > 6)
5523 {
5524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8723 times.
8723 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5525 {
5526 return qe_invalid;
5527 }
5528 8723 }
5529
5530
2/2
✓ Branch 0 taken 29769 times.
✓ Branch 1 taken 9923 times.
39692 for(int32_t j=0; j<3; j++)
5531 {
5532
1/2
✓ Branch 0 taken 29769 times.
✗ Branch 1 not taken.
29769 if(!p_getc(&temp_misc.shop[i].item[j],f))
5533 {
5534 return qe_invalid;
5535 }
5536
5537
2/2
✓ Branch 0 taken 26169 times.
✓ Branch 1 taken 3600 times.
29769 if(s_version < 4)
5538 {
5539 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5540 3600 }
5541 29769 }
5542
5543
2/2
✓ Branch 0 taken 9539 times.
✓ Branch 1 taken 384 times.
9923 if(Header->zelda_version < 0x193)
5544 {
5545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5546 {
5547 return qe_invalid;
5548 }
5549 384 }
5550
5551
2/2
✓ Branch 0 taken 29769 times.
✓ Branch 1 taken 9923 times.
39692 for(int32_t j=0; j<3; j++)
5552 {
5553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29769 times.
29769 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5554 {
5555 return qe_invalid;
5556 }
5557 29769 }
5558
5559
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 8723 times.
9923 if(s_version > 3)
5560 {
5561
2/2
✓ Branch 0 taken 26169 times.
✓ Branch 1 taken 8723 times.
34892 for(int32_t j=0; j<3; j++)
5562 {
5563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26169 times.
26169 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5564 return qe_invalid;
5565 26169 }
5566 8723 }
5567
5568 /*
5569 if(s_version < 8)
5570 {
5571 for(int32_t j=0; j<3; j++)
5572 {
5573 (&temp_misc.shop[i].str[j])=0; //initialise.
5574 }
5575 }
5576 */
5577 9923 }
5578
5579 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5580
2/2
✓ Branch 0 taken 175872 times.
✓ Branch 1 taken 687 times.
176559 for(int32_t i=0; i<maxshops; ++i)
5581 {
5582
2/2
✓ Branch 0 taken 351744 times.
✓ Branch 1 taken 175872 times.
527616 for(int32_t j=0; j<3-1; j++)
5583 {
5584
2/2
✓ Branch 0 taken 351744 times.
✓ Branch 1 taken 512709 times.
864453 for(int32_t k=0; k<2-j; k++)
5585 {
5586 512709 if(temp_misc.shop[i].hasitem[k]==0)
5587 {
5588 512709 swaptmp = temp_misc.shop[i].item[k];
5589 512709 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5590 512709 temp_misc.shop[i].item[k+1] = swaptmp;
5591 512709 swaptmp = temp_misc.shop[i].price[k];
5592 512709 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5593 512709 temp_misc.shop[i].price[k+1] = swaptmp;
5594 512709 swaptmp = temp_misc.shop[i].hasitem[k];
5595 512709 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5596 512709 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5597 512709 }
5598 512709 }
5599 351744 }
5600 175872 }
5601
5602 //infos
5603
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(Header->zelda_version > 0x192)
5604 {
5605
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&infos,f))
5606 {
5607 return qe_invalid;
5608 }
5609 663 }
5610
5611
2/4
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 687 times.
687 if (!(infos >= 0 && infos <= NUM_INFOS))
5612 {
5613 return qe_invalid;
5614 }
5615
5616
5617
2/2
✓ Branch 0 taken 9253 times.
✓ Branch 1 taken 687 times.
9940 for(int32_t i=0; i<infos; i++)
5618 {
5619
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 8492 times.
9253 if(s_version > 6)
5620 {
5621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8492 times.
8492 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5622 {
5623 return qe_invalid;
5624 }
5625 8492 }
5626
5627
2/2
✓ Branch 0 taken 27759 times.
✓ Branch 1 taken 9253 times.
37012 for(int32_t j=0; j<3; j++)
5628 {
5629
3/4
✓ Branch 0 taken 26895 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
28047 if((Header->zelda_version < 0x192)||
5630
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 26607 times.
26895 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5631 {
5632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5633 {
5634 return qe_invalid;
5635 }
5636
5637 864 temp_misc.info[i].str[j]=tempbyte;
5638 864 }
5639 else
5640 {
5641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26895 times.
26895 if(!p_igetw(&temp_misc.info[i].str[j],f))
5642 {
5643 return qe_invalid;
5644 }
5645 }
5646 27759 }
5647
5648
2/2
✓ Branch 0 taken 8869 times.
✓ Branch 1 taken 384 times.
9253 if(Header->zelda_version < 0x193)
5649 {
5650
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5651 {
5652 return qe_invalid;
5653 }
5654 384 }
5655
5656
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 9157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
9253 if((Header->zelda_version == 0x192)&&(Header->build>145))
5657 {
5658
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5659 {
5660 return qe_invalid;
5661 }
5662 96 }
5663
5664
2/2
✓ Branch 0 taken 27759 times.
✓ Branch 1 taken 9253 times.
37012 for(int32_t j=0; j<3; j++)
5665 {
5666
1/2
✓ Branch 0 taken 27759 times.
✗ Branch 1 not taken.
27759 if(!p_igetw(&temp_misc.info[i].price[j],f))
5667 {
5668 return qe_invalid;
5669 }
5670 27759 }
5671 9253 }
5672
5673 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5674
2/2
✓ Branch 0 taken 175872 times.
✓ Branch 1 taken 687 times.
176559 for(int32_t i=0; i<maxinfos; ++i)
5675 {
5676
2/2
✓ Branch 0 taken 351744 times.
✓ Branch 1 taken 175872 times.
527616 for(int32_t j=0; j<3-1; j++)
5677 {
5678
2/2
✓ Branch 0 taken 527616 times.
✓ Branch 1 taken 351744 times.
879360 for(int32_t k=0; k<2-j; k++)
5679 {
5680
2/2
✓ Branch 0 taken 10483 times.
✓ Branch 1 taken 517133 times.
527616 if(temp_misc.info[i].str[k]==0)
5681 {
5682 517133 swaptmp = temp_misc.info[i].str[k];
5683 517133 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5684 517133 temp_misc.info[i].str[k+1] = swaptmp;
5685 517133 swaptmp = temp_misc.info[i].price[k];
5686 517133 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5687 517133 temp_misc.info[i].price[k+1] = swaptmp;
5688 517133 }
5689 527616 }
5690 351744 }
5691 175872 }
5692
5693
5694 //warp rings
5695
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 604 times.
687 if(s_version > 5)
5696 604 warprings++;
5697
5698
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(Header->zelda_version > 0x192)
5699 {
5700
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&warprings,f))
5701 {
5702 return qe_invalid;
5703 }
5704
5705
3/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 103 times.
663 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5706 {
5707 // return qe_invalid;
5708 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5709 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5710 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5711 103 }
5712 663 }
5713
5714
2/2
✓ Branch 0 taken 6694 times.
✓ Branch 1 taken 687 times.
7381 for(int32_t i=0; i<warprings; i++)
5715 {
5716 // See above comment on the `warprings` range check.
5717 6694 bool keepdata = i < NUM_WARP_RINGS;
5718
5719
2/2
✓ Branch 0 taken 59126 times.
✓ Branch 1 taken 6694 times.
65820 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5720 {
5721
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 50166 times.
59126 if(s_version <= 3)
5722 {
5723
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5724 {
5725 return qe_invalid;
5726 }
5727
5728
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5729 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5730 8960 }
5731 else
5732 {
5733 word tempword;
5734
1/2
✓ Branch 0 taken 50166 times.
✗ Branch 1 not taken.
50166 if(!p_igetw(&tempword,f))
5735 {
5736 return qe_invalid;
5737 }
5738
5739
2/2
✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 48924 times.
50166 if (keepdata)
5740 48924 temp_misc.warp[i].dmap[j] = tempword;
5741 }
5742 59126 }
5743
5744
2/2
✓ Branch 0 taken 59126 times.
✓ Branch 1 taken 6694 times.
65820 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5745 {
5746
1/2
✓ Branch 0 taken 59126 times.
✗ Branch 1 not taken.
59126 if(!p_getc(&tempbyte,f))
5747 {
5748 return qe_invalid;
5749 }
5750
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 54692 times.
59126 if (keepdata)
5751 54692 temp_misc.warp[i].scr[j] = tempbyte;
5752 59126 }
5753
5754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6694 times.
6694 if(!p_getc(&tempbyte,f))
5755 {
5756 return qe_invalid;
5757 }
5758
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 6157 times.
6694 if (keepdata)
5759 6157 temp_misc.warp[i].size = tempbyte;
5760
5761
2/2
✓ Branch 0 taken 6502 times.
✓ Branch 1 taken 192 times.
6694 if(Header->zelda_version < 0x193)
5762 {
5763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5764 {
5765 return qe_invalid;
5766 }
5767 192 }
5768 6694 }
5769
5770 //palette cycles
5771
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5772 {
5773
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5774 {
5775
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5776 {
5777 18432 temp_misc.cycles[i][j].first=0;
5778 18432 temp_misc.cycles[i][j].count=0;
5779 18432 temp_misc.cycles[i][j].speed=0;
5780 18432 }
5781 6144 }
5782
5783
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5784
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5785 {
5786 18 palcycles=16;
5787 18 }
5788
5789
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5790 {
5791
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5792 {
5793
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5794 {
5795 return qe_invalid;
5796 }
5797
5798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5799 {
5800 return qe_invalid;
5801 }
5802
5803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5804 {
5805 return qe_invalid;
5806 }
5807 5472 }
5808 1824 }
5809 24 }
5810
5811 //Wind warps are now just another warp ring.
5812
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 83 times.
687 if(s_version <= 5)
5813 {
5814
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5815 {
5816
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5817 {
5818 return qe_invalid;
5819 }
5820 59 }
5821
5822
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
83 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5823 {
5824 return qe_invalid;
5825 }
5826
5827
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5828 {
5829
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5830 {
5831
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5832 {
5833 return qe_invalid;
5834 }
5835
5836 665 temp_misc.warp[8].dmap[i]=tempbyte;
5837 665 }
5838 else
5839 {
5840 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5841 {
5842 return qe_invalid;
5843 }
5844 }
5845
5846
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5847 {
5848 return qe_invalid;
5849 }
5850
5851 665 temp_misc.warp[8].size = 9;
5852
5853
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5854 {
5855 if(!p_getc(&tempbyte,f))
5856 {
5857 return qe_invalid;
5858 }
5859 }
5860 665 }
5861 83 }
5862
5863
5864 //triforce pieces
5865
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 687 times.
6183 for(int32_t i=0; i<triforces; i++)
5866 {
5867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5496 times.
5496 if(!p_getc(&temp_misc.triforce[i],f))
5868 {
5869 return qe_invalid;
5870 }
5871 5496 }
5872
5873 //misc color data
5874
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 83 times.
687 if(s_version<3)
5875 {
5876
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5877 {
5878 return qe_invalid;
5879 }
5880
5881
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5882 {
5883 return qe_invalid;
5884 }
5885
5886
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5887 {
5888 return qe_invalid;
5889 }
5890
5891
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5892 {
5893 return qe_invalid;
5894 }
5895
5896
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5897 {
5898 return qe_invalid;
5899 }
5900
5901
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5902 {
5903 return qe_invalid;
5904 }
5905
5906
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5907 {
5908 return qe_invalid;
5909 }
5910
5911
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5912 {
5913 return qe_invalid;
5914 }
5915
5916
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5917 {
5918 return qe_invalid;
5919 }
5920
5921
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5922 {
5923 return qe_invalid;
5924 }
5925
5926
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5927 {
5928 return qe_invalid;
5929 }
5930
5931
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5932 {
5933 return qe_invalid;
5934 }
5935
5936
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5937 {
5938 return qe_invalid;
5939 }
5940
5941
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5942 {
5943 return qe_invalid;
5944 }
5945
5946
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5947 {
5948 return qe_invalid;
5949 }
5950
5951
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5952 {
5953 return qe_invalid;
5954 }
5955
5956
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5957 {
5958 return qe_invalid;
5959 }
5960
5961
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5962 {
5963 return qe_invalid;
5964 }
5965
5966
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5967 {
5968 return qe_invalid;
5969 }
5970
5971
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5972 {
5973 return qe_invalid;
5974 }
5975
5976
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5977 {
5978 return qe_invalid;
5979 }
5980
5981
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5982 {
5983 return qe_invalid;
5984 }
5985
5986
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5987 {
5988 return qe_invalid;
5989 }
5990
5991
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5992 {
5993 return qe_invalid;
5994 }
5995
5996
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5997 {
5998 return qe_invalid;
5999 }
6000
6001
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6002 {
6003 return qe_invalid;
6004 }
6005
6006
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6007 {
6008 return qe_invalid;
6009 }
6010
6011 83 temp_misc.colors.msgtext = 0x01;
6012
6013
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
6014 {
6015
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6016 {
6017
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
6018 {
6019 return qe_invalid;
6020 }
6021 168 }
6022 24 }
6023
6024
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6025 {
6026
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6027 {
6028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6029 {
6030 return qe_invalid;
6031 }
6032 1536 }
6033 6 }
6034
6035
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6036 {
6037 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6038 {
6039 return qe_invalid;
6040 }
6041 }
6042
6043 //save game icons
6044
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6045
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6046 {
6047 18 icons=3;
6048 18 }
6049
6050
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6051 {
6052
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6053 {
6054 return qe_invalid;
6055 }
6056 314 }
6057 83 }
6058
6059
3/4
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
693 if((Header->zelda_version < 0x192)||
6060
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 663 times.
669 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6061 {
6062 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6063
6064 18 return 0;
6065 }
6066
6067 //pond information
6068
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 6 times.
669 if(Header->zelda_version < 0x193)
6069 {
6070
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6071 {
6072 pondsize=25;
6073 }
6074
6075
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6076 {
6077
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6078 {
6079
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6080 {
6081 return qe_invalid;
6082
6083 }
6084 6912 }
6085 96 }
6086 6 }
6087
6088 //end string
6089
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
675 if((Header->zelda_version < 0x192)||
6090
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 663 times.
669 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6091 {
6092 if(!p_getc(&tempbyte,f))
6093 {
6094 return qe_invalid;
6095 }
6096
6097 temp_misc.endstring=tempbyte;
6098
6099 if(!p_getc(&tempbyte,f))
6100 {
6101 return qe_invalid;
6102 }
6103 }
6104 else
6105 {
6106
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&temp_misc.endstring,f))
6107 {
6108 return qe_invalid;
6109 }
6110 }
6111
6112 //expansion
6113
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 6 times.
669 if(Header->zelda_version < 0x193)
6114 {
6115
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6116 {
6117 expansionsize=99*2;
6118 }
6119
6120
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6121 {
6122
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6123 {
6124 return qe_invalid;
6125 }
6126 1176 }
6127 6 }
6128 //shops v8
6129
6130
6131
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 419 times.
669 if(s_version >= 8)
6132 {
6133
2/2
✓ Branch 0 taken 6544 times.
✓ Branch 1 taken 419 times.
6963 for(int32_t i=0; i<shops; i++)
6134 {
6135
2/2
✓ Branch 0 taken 19632 times.
✓ Branch 1 taken 6544 times.
26176 for(int32_t j=0; j<3; j++)
6136 {
6137
1/2
✓ Branch 0 taken 19632 times.
✗ Branch 1 not taken.
19632 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6138 return qe_invalid;
6139 19632 }
6140 6544 }
6141 419 }
6142
6143 669 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6144 669 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6145 669 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6146
6147 //v9 includes quest misc[32]
6148
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 419 times.
669 if(s_version >= 9)
6149 {
6150
2/2
✓ Branch 0 taken 13408 times.
✓ Branch 1 taken 419 times.
13827 for ( int32_t q = 0; q < 32; q++ )
6151 {
6152
1/2
✓ Branch 0 taken 13408 times.
✗ Branch 1 not taken.
13408 if(!p_igetl(&temp_misc.questmisc[q],f))
6153 return qe_invalid;
6154 13408 }
6155
2/2
✓ Branch 0 taken 13408 times.
✓ Branch 1 taken 419 times.
13827 for ( int32_t q = 0; q < 32; q++ )
6156 {
6157
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 13408 times.
1729632 for ( int32_t j = 0; j < 128; j++ )
6158
1/2
✓ Branch 0 taken 1716224 times.
✗ Branch 1 not taken.
1716224 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6159 return qe_invalid;
6160 13408 }
6161 419 }
6162
6163
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 250 times.
669 if(s_version >= 11 )
6164 {
6165
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6166 return qe_invalid;
6167 419 }
6168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 else if(s_version < 11 )
6169 {
6170 250 temp_misc.zscript_last_compiled_version = -1;
6171 250 }
6172
6173 669 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6174
6175
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 250 times.
669 if(s_version >= 12)
6176 {
6177 byte spr;
6178
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(int32_t q = 0; q < sprMAX; ++q)
6179 {
6180
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_getc(&spr,f))
6181 return qe_invalid;
6182 107264 temp_misc.sprites[q] = spr;
6183 107264 }
6184 419 }
6185 else
6186 {
6187 250 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6188 //temp_misc.sprites[sprFALL] = ;
6189 }
6190
6191
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 250 times.
669 if(s_version >= 13)
6192 {
6193
2/2
✓ Branch 0 taken 26816 times.
✓ Branch 1 taken 419 times.
27235 for(size_t q = 0; q < 64; ++q)
6194 {
6195 26816 bottletype* bt = &(temp_misc.bottle_types[q]);
6196
1/2
✓ Branch 0 taken 26816 times.
✗ Branch 1 not taken.
26816 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6197 return qe_invalid;
6198
2/2
✓ Branch 0 taken 80448 times.
✓ Branch 1 taken 26816 times.
107264 for(size_t j = 0; j < 3; ++j)
6199 {
6200
1/2
✓ Branch 0 taken 80448 times.
✗ Branch 1 not taken.
80448 if (!p_getc(&(bt->counter[j]), f))
6201 return qe_invalid;
6202
1/2
✓ Branch 0 taken 80448 times.
✗ Branch 1 not taken.
80448 if (!p_igetw(&(bt->amount[j]), f))
6203 return qe_invalid;
6204 80448 }
6205
1/2
✓ Branch 0 taken 26816 times.
✗ Branch 1 not taken.
26816 if (!p_getc(&(bt->flags), f))
6206 return qe_invalid;
6207
1/2
✓ Branch 0 taken 26816 times.
✗ Branch 1 not taken.
26816 if (!p_getc(&(bt->next_type), f))
6208 return qe_invalid;
6209 26816 }
6210
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(size_t q = 0; q < 256; ++q)
6211 {
6212 107264 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6213
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6214 return qe_invalid;
6215
2/2
✓ Branch 0 taken 321792 times.
✓ Branch 1 taken 107264 times.
429056 for(size_t j = 0; j < 3; ++j)
6216 {
6217
1/2
✓ Branch 0 taken 321792 times.
✗ Branch 1 not taken.
321792 if (!p_getc(&(bst->fill[j]), f))
6218 return qe_invalid;
6219
1/2
✓ Branch 0 taken 321792 times.
✗ Branch 1 not taken.
321792 if (!p_igetw(&(bst->comb[j]), f))
6220 return qe_invalid;
6221
1/2
✓ Branch 0 taken 321792 times.
✗ Branch 1 not taken.
321792 if (!p_getc(&(bst->cset[j]), f))
6222 return qe_invalid;
6223
1/2
✓ Branch 0 taken 321792 times.
✗ Branch 1 not taken.
321792 if (!p_igetw(&(bst->price[j]), f))
6224 return qe_invalid;
6225
1/2
✓ Branch 0 taken 321792 times.
✗ Branch 1 not taken.
321792 if (!p_igetw(&(bst->str[j]), f))
6226 return qe_invalid;
6227 321792 }
6228 107264 }
6229 419 }
6230 else
6231 {
6232
2/2
✓ Branch 0 taken 16000 times.
✓ Branch 1 taken 250 times.
16250 for(size_t q = 0; q < 64; ++q)
6233 16000 temp_misc.bottle_types[q].clear();
6234
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 250 times.
64250 for(size_t q = 0; q < 256; ++q)
6235 64000 temp_misc.bottle_shop_types[q].clear();
6236 }
6237
6238
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 250 times.
669 if(s_version >= 14)
6239 {
6240 byte msfx;
6241
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(int32_t q = 0; q < sfxMAX; ++q)
6242 {
6243
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_getc(&msfx,f))
6244 return qe_invalid;
6245 107264 temp_misc.miscsfx[q] = msfx;
6246 107264 }
6247 419 }
6248 else
6249 {
6250 250 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6251 250 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6252 250 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6253 }
6254
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 250 times.
669 if(s_version < 15)
6255 {
6256 250 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6257 250 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6258 250 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6259 250 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6260 250 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6261 250 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6262 250 }
6263
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 268 times.
669 if(s_version < 16)
6264 {
6265 268 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6266 268 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6267 268 }
6268
6269
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 668 times.
669 if (!should_skip)
6270 668 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6271
6272 669 return 0;
6273 687 }
6274
6275 extern char *item_string[MAXITEMS];
6276 extern const char *old_item_string[iLast];
6277 extern char *weapon_string[MAXWPNS];
6278 extern const char *old_weapon_string[wLast];
6279
6280 687 int32_t readitems(PACKFILE *f, word version, word build)
6281 {
6282
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6283
6284 byte padding;
6285 int32_t dummy;
6286 687 word items_to_read=MAXITEMS;
6287 itemdata tempitem;
6288 687 word s_version=0, s_cversion=0;
6289 word dummy_word;
6290
6291
2/2
✓ Branch 0 taken 681 times.
✓ Branch 1 taken 6 times.
687 if(version < 0x186)
6292 {
6293 6 items_to_read=64;
6294 6 }
6295
6296
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(version > 0x192)
6297 {
6298 663 items_to_read=0;
6299
6300 //section version info
6301
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
6302 {
6303 return qe_invalid;
6304 }
6305
6306 663 FFCore.quest_format[vItems] = s_version;
6307
6308 //al_trace("Items version %d\n", s_version);
6309
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_cversion,f))
6310 {
6311 return qe_invalid;
6312 }
6313
6314 //section size
6315
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
6316 {
6317 return qe_invalid;
6318 }
6319
6320 //finally... section data
6321
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&items_to_read,f))
6322 {
6323 return qe_invalid;
6324 }
6325
6326
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6327 {
6328 return qe_invalid;
6329 }
6330 663 }
6331
6332
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 83 times.
687 if(s_version>1)
6333 {
6334
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 604 times.
155228 for(int32_t i=0; i<items_to_read; i++)
6335 {
6336 char tempname[64];
6337
6338
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!pfread(tempname, 64, f))
6339 {
6340 return qe_invalid;
6341 }
6342
6343 154624 item_string[i][0] = '\0';
6344 154624 strncat(item_string[i], tempname, 64 - 1);
6345 154624 }
6346 604 }
6347
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6348 {
6349
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6350 {
6351 20992 reset_itemname(i);
6352 20992 }
6353 82 }
6354
6355
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if (!should_skip)
6356
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<MAXITEMS; i++)
6357 {
6358 175616 itemdata& id = itemsbuf[i];
6359 175616 memset(&id, 0, sizeof(itemdata));
6360 175616 id.count=-1;
6361 175616 id.playsound=WAV_SCALE;
6362 175616 reset_itembuf(&id,i);
6363 176302 }
6364
6365
2/2
✓ Branch 0 taken 163746 times.
✓ Branch 1 taken 687 times.
164433 for(int32_t i=0; i<items_to_read; i++)
6366 {
6367 163746 memset(&tempitem, 0, sizeof(itemdata));
6368 163746 reset_itembuf(&tempitem,i);
6369
6370
6371
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 56482 times.
163746 if ( s_version > 35 ) //expanded tiles
6372 {
6373
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.tile,f))
6374 {
6375 return qe_invalid;
6376 }
6377 107264 }
6378 else
6379 {
6380
1/2
✓ Branch 0 taken 56482 times.
✗ Branch 1 not taken.
56482 if(!p_igetw(&tempitem.tile,f))
6381 {
6382 return qe_invalid;
6383 }
6384 }
6385
6386
1/2
✓ Branch 0 taken 163746 times.
✗ Branch 1 not taken.
163746 if(!p_getc(&tempitem.misc_flags,f))
6387 {
6388 return qe_invalid;
6389 }
6390
6391
1/2
✓ Branch 0 taken 163746 times.
✗ Branch 1 not taken.
163746 if(!p_getc(&tempitem.csets,f))
6392 {
6393 return qe_invalid;
6394 }
6395
6396
1/2
✓ Branch 0 taken 163746 times.
✗ Branch 1 not taken.
163746 if(!p_getc(&tempitem.frames,f))
6397 {
6398 return qe_invalid;
6399 }
6400
6401
1/2
✓ Branch 0 taken 163746 times.
✗ Branch 1 not taken.
163746 if(!p_getc(&tempitem.speed,f))
6402 {
6403 return qe_invalid;
6404 }
6405
6406
1/2
✓ Branch 0 taken 163746 times.
✗ Branch 1 not taken.
163746 if(!p_getc(&tempitem.delay,f))
6407 {
6408 return qe_invalid;
6409 }
6410
6411
2/2
✓ Branch 0 taken 158754 times.
✓ Branch 1 taken 4992 times.
163746 if(version < 0x193)
6412 {
6413
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6414 {
6415 return qe_invalid;
6416 }
6417
6418
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6419 {
6420
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6421 256 continue;
6422
6423
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6424 {
6425 case iShield:
6426 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6427 23 break;
6428
6429 case iMShield:
6430 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6431 23 break;
6432
6433 default:
6434 4690 tempitem.ltm=0;
6435 4690 break;
6436 }
6437
6438 4736 tempitem.count=-1;
6439 4736 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6440 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6441 4736 tempitem.family=0xFF;
6442 4736 tempitem.playsound=WAV_SCALE;
6443 4736 reset_itembuf(&tempitem,i);
6444
6445 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6446
6447 4736 continue;
6448 }
6449 }
6450
6451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158754 times.
158754 if(!p_igetl(&tempitem.ltm,f))
6452 {
6453 return qe_invalid;
6454 }
6455
6456
1/2
✓ Branch 0 taken 158754 times.
✗ Branch 1 not taken.
158754 if(version < 0x193)
6457 {
6458 for(int32_t q=0; q<12; q++)
6459 {
6460 if(!p_getc(&padding,f))
6461 {
6462 return qe_invalid;
6463 }
6464 }
6465 }
6466
6467
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 4130 times.
158754 if(s_version>1)
6468 {
6469
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 47360 times.
154624 if ( s_version >= 31 )
6470 {
6471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.family,f))
6472 {
6473 return qe_invalid;
6474 }
6475 107264 }
6476 else
6477 {
6478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47360 times.
47360 if(!p_getc(&tempitem.family,f))
6479 {
6480 return qe_invalid;
6481 }
6482 }
6483
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(s_version < 16)
6484 if(tempitem.family == 0xFF)
6485 tempitem.family = itype_misc;
6486
6487
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.fam_type,f))
6488 {
6489 return qe_invalid;
6490 }
6491
6492
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(s_version>5)
6493 {
6494
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 47360 times.
154624 if(s_version>=31)
6495 {
6496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.power,f))
6497 {
6498 return qe_invalid;
6499 }
6500 107264 }
6501 else
6502 {
6503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47360 times.
47360 if(!p_getc(&tempitem.power,f))
6504 {
6505 return qe_invalid;
6506 }
6507 }
6508
6509 //converted flags from 16b to 32b -Z
6510
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version < 41 )
6511 {
6512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47360 times.
47360 if(!p_igetw(&tempitem.flags,f))
6513 {
6514 return qe_invalid;
6515 }
6516 47360 }
6517 else
6518 {
6519
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.flags,f))
6520 {
6521 return qe_invalid;
6522 }
6523 }
6524 154624 }
6525 else
6526 {
6527 //tempitem.power = tempitem.fam_type;
6528 char tempchar;
6529
6530 if(!p_getc(&tempchar,f))
6531 {
6532 return qe_invalid;
6533 }
6534
6535 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6536 }
6537
6538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_igetw(&tempitem.script,f))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(s_version<=3)
6544 {
6545 if(tempitem.script > NUMSCRIPTITEM)
6546 {
6547 tempitem.script = 0;
6548 }
6549 }
6550
6551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_getc(&tempitem.count,f))
6552 {
6553 return qe_invalid;
6554 }
6555
6556
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetw(&tempitem.amount,f))
6557 {
6558 return qe_invalid;
6559 }
6560
6561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_igetw(&tempitem.collect_script,f))
6562 {
6563 return qe_invalid;
6564 }
6565
6566
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(s_version<=3)
6567 {
6568 if(tempitem.collect_script > NUMSCRIPTITEM)
6569 {
6570 tempitem.collect_script = 0;
6571 }
6572 }
6573
6574
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetw(&tempitem.setmax,f))
6575 {
6576 return qe_invalid;
6577 }
6578
6579
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetw(&tempitem.max,f))
6580 {
6581 return qe_invalid;
6582 }
6583
6584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_getc(&tempitem.playsound,f))
6585 {
6586 return qe_invalid;
6587 }
6588
6589
2/2
✓ Branch 0 taken 1236992 times.
✓ Branch 1 taken 154624 times.
1391616 for(int32_t j=0; j<8; j++)
6590 {
6591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1236992 times.
1236992 if(!p_igetl(&tempitem.initiald[j],f))
6592 {
6593 return qe_invalid;
6594 }
6595 1236992 }
6596
6597
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 154624 times.
463872 for(int32_t j=0; j<2; j++)
6598 {
6599
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&tempitem.initiala[j],f))
6600 {
6601 return qe_invalid;
6602 }
6603 309248 }
6604
6605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(s_version>4)
6606 {
6607
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(s_version>5)
6608 {
6609
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn,f))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_getc(&tempitem.wpn2,f))
6615 {
6616 return qe_invalid;
6617 }
6618
6619
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn3,f))
6620 {
6621 return qe_invalid;
6622 }
6623
6624
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn4,f))
6625 {
6626 return qe_invalid;
6627 }
6628
6629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(s_version>=15)
6630 {
6631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_getc(&tempitem.wpn5,f))
6632 {
6633 return qe_invalid;
6634 }
6635
6636
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn6,f))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn7,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn8,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_getc(&tempitem.wpn9,f))
6652 {
6653 return qe_invalid;
6654 }
6655
6656
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.wpn10,f))
6657 {
6658 return qe_invalid;
6659 }
6660 154624 }
6661
6662
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_getc(&tempitem.pickup_hearts,f))
6663 {
6664 return qe_invalid;
6665 }
6666
6667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(s_version<15)
6668 {
6669 if(!p_igetw(&dummy_word,f))
6670 {
6671 return qe_invalid;
6672 }
6673
6674 tempitem.misc1=dummy_word;
6675
6676 if(!p_igetw(&dummy_word,f))
6677 {
6678 return qe_invalid;
6679 }
6680
6681 tempitem.misc2=dummy_word;
6682 }
6683 else
6684 {
6685
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetl(&tempitem.misc1,f))
6686 {
6687 return qe_invalid;
6688 }
6689
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_igetl(&tempitem.misc2,f))
6691 {
6692 return qe_invalid;
6693 }
6694
6695 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6696
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(s_version<24)
6697 {
6698 if(tempitem.family==itype_shield)
6699 {
6700 tempitem.misc1|=shSCRIPT;
6701 }
6702 }
6703 }
6704
6705
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if(s_version < 53)
6706 {
6707 byte tempbyte;
6708
1/2
✓ Branch 0 taken 47360 times.
✗ Branch 1 not taken.
47360 if(!p_getc(&tempbyte,f))
6709 {
6710 return qe_invalid;
6711 }
6712 47360 tempitem.cost_amount[0] = tempbyte;
6713 47360 }
6714 else
6715 {
6716
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 107264 times.
321792 for(auto q = 0; q < 2; ++q)
6717 {
6718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214528 times.
214528 if(!p_igetw(&tempitem.cost_amount[q],f))
6719 {
6720 return qe_invalid;
6721 }
6722 214528 }
6723 }
6724 154624 }
6725 else
6726 {
6727 char tempchar;
6728
6729 if(!p_getc(&tempchar,f))
6730 {
6731 return qe_invalid;
6732 }
6733
6734 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6735 }
6736
6737 // June 2007: more misc. attributes
6738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(s_version>=12)
6739 {
6740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(s_version<15)
6741 {
6742 if(!p_igetw(&dummy_word,f))
6743 {
6744 return qe_invalid;
6745 }
6746
6747 tempitem.misc3=dummy_word;
6748
6749 if(!p_igetw(&dummy_word,f))
6750 {
6751 return qe_invalid;
6752 }
6753
6754 tempitem.misc4=dummy_word;
6755 }
6756 else
6757 {
6758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_igetl(&tempitem.misc3,f))
6759 {
6760 return qe_invalid;
6761 }
6762
6763
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetl(&tempitem.misc4,f))
6764 {
6765 return qe_invalid;
6766 }
6767
6768
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetl(&tempitem.misc5,f))
6769 {
6770 return qe_invalid;
6771 }
6772
6773
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetl(&tempitem.misc6,f))
6774 {
6775 return qe_invalid;
6776 }
6777
6778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_igetl(&tempitem.misc7,f))
6779 {
6780 return qe_invalid;
6781 }
6782
6783
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetl(&tempitem.misc8,f))
6784 {
6785 return qe_invalid;
6786 }
6787
6788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_igetl(&tempitem.misc9,f))
6789 {
6790 return qe_invalid;
6791 }
6792
6793
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!p_igetl(&tempitem.misc10,f))
6794 {
6795 return qe_invalid;
6796 }
6797 }
6798
6799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154624 times.
154624 if(!p_getc(&tempitem.usesound,f))
6800 {
6801 return qe_invalid;
6802 }
6803
6804
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 47360 times.
154624 if(s_version >= 49)
6805 {
6806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_getc(&tempitem.usesound2,f))
6807 {
6808 return qe_invalid;
6809 }
6810 107264 }
6811 47360 else tempitem.usesound2 = 0;
6812
6813
3/4
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
✓ Branch 2 taken 47360 times.
✗ Branch 3 not taken.
154624 if(s_version < 50 && tempitem.family == itype_mirror)
6814 {
6815 //Split continue/dmap warp effect/sfx, port for old
6816 tempitem.misc2 = tempitem.misc1;
6817 tempitem.usesound2 = tempitem.usesound;
6818 }
6819 154624 }
6820 154624 }
6821
6822
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6823 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_getc(&tempitem.useweapon,f))
6825 {
6826 return qe_invalid;
6827 }
6828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_getc(&tempitem.usedefence,f))
6829 {
6830 return qe_invalid;
6831 }
6832
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.weaprange,f))
6833 {
6834 return qe_invalid;
6835 }
6836
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.weapduration,f))
6837 {
6838 return qe_invalid;
6839 }
6840
2/2
✓ Branch 0 taken 1072640 times.
✓ Branch 1 taken 107264 times.
1179904 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6841 {
6842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1072640 times.
1072640 if(!p_igetl(&tempitem.weap_pattern[q],f))
6843 {
6844 return qe_invalid;
6845 }
6846 1072640 }
6847 107264 }
6848
6849
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6850 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6851
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.duplicates,f))
6852 {
6853 return qe_invalid;
6854 }
6855
2/2
✓ Branch 0 taken 858112 times.
✓ Branch 1 taken 107264 times.
965376 for ( int32_t q = 0; q < INITIAL_D; q++ )
6856 {
6857
1/2
✓ Branch 0 taken 858112 times.
✗ Branch 1 not taken.
858112 if(!p_igetl(&tempitem.weap_initiald[q],f))
6858 {
6859 return qe_invalid;
6860 }
6861 858112 }
6862
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 107264 times.
321792 for ( int32_t q = 0; q < INITIAL_A; q++ )
6863 {
6864
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_getc(&tempitem.weap_initiala[q],f))
6865 {
6866 return qe_invalid;
6867 }
6868 214528 }
6869
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_getc(&tempitem.drawlayer,f))
6871 {
6872 return qe_invalid;
6873 }
6874
6875
6876
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.hxofs,f))
6877 {
6878 return qe_invalid;
6879 }
6880
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.hyofs,f))
6881 {
6882 return qe_invalid;
6883 }
6884
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.hxsz,f))
6885 {
6886 return qe_invalid;
6887 }
6888
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.hysz,f))
6889 {
6890 return qe_invalid;
6891 }
6892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.hzsz,f))
6893 {
6894 return qe_invalid;
6895 }
6896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.xofs,f))
6897 {
6898 return qe_invalid;
6899 }
6900
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.yofs,f))
6901 {
6902 return qe_invalid;
6903 }
6904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.weap_hxofs,f))
6905 {
6906 return qe_invalid;
6907 }
6908
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.weap_hyofs,f))
6909 {
6910 return qe_invalid;
6911 }
6912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.weap_hxsz,f))
6913 {
6914 return qe_invalid;
6915 }
6916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.weap_hysz,f))
6917 {
6918 return qe_invalid;
6919 }
6920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.weap_hzsz,f))
6921 {
6922 return qe_invalid;
6923 }
6924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.weap_xofs,f))
6925 {
6926 return qe_invalid;
6927 }
6928
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.weap_yofs,f))
6929 {
6930 return qe_invalid;
6931 }
6932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetw(&tempitem.weaponscript,f))
6933 {
6934 return qe_invalid;
6935 }
6936
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.wpnsprite,f))
6937 {
6938 return qe_invalid;
6939 }
6940 107264 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6941
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 107264 times.
321792 for(auto q = 0; q < num_cost_tmr; ++q)
6942 {
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214528 times.
214528 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6944 {
6945 return qe_invalid;
6946 }
6947 214528 }
6948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 for(auto q = num_cost_tmr; q < 2; ++q)
6949 tempitem.magiccosttimer[q] = 0;
6950 107264 }
6951
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6952 {
6953 //Item Size FLags, TileWidth, TileHeight
6954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.overrideFLAGS,f))
6955 {
6956 return qe_invalid;
6957 }
6958
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.tilew,f))
6959 {
6960 return qe_invalid;
6961 }
6962
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.tileh,f))
6963 {
6964 return qe_invalid;
6965 }
6966 107264 }
6967
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 29 ) //! More new vars.
6968 {
6969 //Item Size FLags, TileWidth, TileHeight
6970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6971 {
6972 return qe_invalid;
6973 }
6974
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.weap_tilew,f))
6975 {
6976 return qe_invalid;
6977 }
6978
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.weap_tileh,f))
6979 {
6980 return qe_invalid;
6981 }
6982 107264 }
6983
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 30 ) //! More new vars.
6984 {
6985 //Pickup Type
6986
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempitem.pickup,f))
6987 {
6988 return qe_invalid;
6989 }
6990 107264 }
6991
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 32 ) //! More new vars.
6992 {
6993 //Pickup Type
6994
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetw(&tempitem.pstring,f))
6995 {
6996 return qe_invalid;
6997 }
6998 107264 }
6999
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 33 ) //! More new vars.
7000 {
7001 //Pickup Type
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(!p_igetw(&tempitem.pickup_string_flags,f))
7003 {
7004 return qe_invalid;
7005 }
7006 107264 }
7007
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 34 ) //! cost counter
7008 {
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107264 times.
107264 if(s_version < 53)
7010 {
7011 if(!p_getc(&tempitem.cost_counter[0],f))
7012 {
7013 return qe_invalid;
7014 }
7015 }
7016 else
7017 {
7018
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 107264 times.
321792 for(auto q = 0; q < 2; ++q)
7019 {
7020
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_getc(&tempitem.cost_counter[q],f))
7021 {
7022 return qe_invalid;
7023 }
7024 214528 }
7025 }
7026 107264 }
7027
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 44 ) //! sprite scripts
7028 {
7029
2/2
✓ Branch 0 taken 858112 times.
✓ Branch 1 taken 107264 times.
965376 for ( int32_t q = 0; q < 8; q++ )
7030 {
7031
2/2
✓ Branch 0 taken 55777280 times.
✓ Branch 1 taken 858112 times.
56635392 for ( int32_t w = 0; w < 65; w++ )
7032 {
7033
1/2
✓ Branch 0 taken 55777280 times.
✗ Branch 1 not taken.
55777280 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7034 {
7035 return qe_invalid;
7036 }
7037 55777280 }
7038
2/2
✓ Branch 0 taken 55777280 times.
✓ Branch 1 taken 858112 times.
56635392 for ( int32_t w = 0; w < 65; w++ )
7039 {
7040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55777280 times.
55777280 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7041 {
7042 return qe_invalid;
7043 }
7044 55777280 }
7045
2/2
✓ Branch 0 taken 55777280 times.
✓ Branch 1 taken 858112 times.
56635392 for ( int32_t w = 0; w < 65; w++ )
7046 {
7047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55777280 times.
55777280 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7048 {
7049 return qe_invalid;
7050 }
7051 55777280 }
7052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 858112 times.
858112 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7053 {
7054 return qe_invalid;
7055 }
7056
7057 858112 }
7058
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 107264 times.
321792 for ( int32_t q = 0; q < 2; q++ )
7059 {
7060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214528 times.
214528 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7061 {
7062 return qe_invalid;
7063 }
7064 214528 }
7065 //Pickup Type
7066
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetw(&tempitem.sprite_script,f))
7067 {
7068 return qe_invalid;
7069 }
7070 107264 }
7071
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 107264 times.
154624 if ( s_version >= 48 ) //! pickup flags
7072 {
7073
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_getc(&(tempitem.pickupflag),f))
7074 {
7075 return qe_invalid;
7076 }
7077 107264 }
7078
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 103936 times.
154624 if ( s_version >= 57 )
7079 {
7080 103936 std::string str;
7081
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103936 times.
✓ Branch 2 taken 103936 times.
✗ Branch 3 not taken.
103936 if(!p_getcstr(&str,f))
7082 return qe_invalid;
7083 103936 strncpy(tempitem.display_name,str.c_str(),255);
7084
1/3
✓ Branch 0 taken 103936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
103936 }
7085 154624 }
7086 else
7087 {
7088 4130 tempitem.count=-1;
7089 4130 tempitem.family=itype_misc;
7090 4130 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7091 4130 tempitem.playsound=WAV_SCALE;
7092 4130 reset_itembuf(&tempitem,i);
7093 }
7094
7095
2/2
✓ Branch 0 taken 56098 times.
✓ Branch 1 taken 102656 times.
158754 if(s_version >= 58)
7096 {
7097
2/2
✓ Branch 0 taken 513280 times.
✓ Branch 1 taken 102656 times.
615936 for(int q = 0; q < BURNSPR_MAX; ++q)
7098 {
7099
1/2
✓ Branch 0 taken 513280 times.
✗ Branch 1 not taken.
513280 if(!p_getc(&tempitem.burnsprs[q],f))
7100 return qe_invalid;
7101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 513280 times.
513280 if(s_version >= 59)
7102
1/2
✓ Branch 0 taken 513280 times.
✗ Branch 1 not taken.
513280 if(!p_getc(&tempitem.light_rads[q],f))
7103 return qe_invalid;
7104 513280 }
7105 102656 }
7106
7107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158754 times.
158754 if (!should_skip)
7108 {
7109
1/2
✓ Branch 0 taken 158754 times.
✗ Branch 1 not taken.
158754 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7110 {
7111 tempitem.script = 0;
7112 tempitem.weaponscript = 0;
7113 for(int q = 0; q < 8; ++q)
7114 {
7115 tempitem.initiald[q] = 0;
7116 tempitem.weap_initiald[q] = 0;
7117 }
7118 }
7119 158754 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7120 158754 }
7121 158754 }
7122
7123
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if (should_skip)
7124 1 return 0;
7125
7126 //////////////////////////////////////////////////////
7127 // Now do any updates because of new item additions
7128 // (These can't be done above because items_to_read
7129 // might be too low.)
7130 //////////////////////////////////////////////////////
7131
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<MAXITEMS; i++)
7132 {
7133 175616 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7134
7135 //Account for older quests that didn't have an actual item for the used letter
7136
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 154624 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
175616 if(s_version < 2 && i==iLetterUsed)
7137 {
7138 82 reset_itembuf(&tempitem, iLetterUsed);
7139 82 strcpy(item_string[i],old_item_string[i]);
7140 82 tempitem.tile = itemsbuf[iLetter].tile;
7141 82 tempitem.csets = itemsbuf[iLetter].csets;
7142 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7143 82 tempitem.frames = itemsbuf[iLetter].frames;
7144 82 tempitem.speed = itemsbuf[iLetter].speed;
7145 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7146 82 }
7147
7148
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 3)
7149 {
7150
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7151 {
7152 case iRocsFeather:
7153 case iHoverBoots:
7154 case iSpinScroll:
7155 case iL2SpinScroll:
7156 case iCrossScroll:
7157 case iQuakeScroll:
7158 case iL2QuakeScroll:
7159 case iWhispRing:
7160 case iL2WhispRing:
7161 case iChargeRing:
7162 case iL2ChargeRing:
7163 case iPerilScroll:
7164 case iWalletL3:
7165 case iQuiverL4:
7166 case iBombBagL4:
7167 case iBracelet:
7168 case iL2Bracelet:
7169 case iOldGlove:
7170 case iL2Ladder:
7171 case iWealthMedal:
7172 case iL2WealthMedal:
7173 case iL3WealthMedal:
7174 1804 reset_itembuf(&tempitem, i);
7175 1804 strcpy(item_string[i],old_item_string[i]);
7176 1804 break;
7177
7178 case iSShield:
7179 82 reset_itembuf(&tempitem, i);
7180 82 strcpy(item_string[i],old_item_string[i]);
7181 82 strcpy(item_string[iShield],old_item_string[iShield]);
7182 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7183 82 break;
7184 }
7185 20992 }
7186
7187
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 5)
7188 {
7189
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7190 {
7191 case iHeartRing:
7192 case iL2HeartRing:
7193 case iL3HeartRing:
7194 case iMagicRing:
7195 case iL2MagicRing:
7196 case iL3MagicRing:
7197 case iL4MagicRing:
7198 574 reset_itembuf(&tempitem, i);
7199 574 strcpy(item_string[i],old_item_string[i]);
7200 574 break;
7201 }
7202 20992 }
7203
7204
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7205 {
7206
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7207 20828 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7208
7209
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 328 times.
✓ Branch 8 taken 17302 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7210 {
7211 case iTriforce:
7212 82 tempitem.fam_type=1;
7213 82 break;
7214
7215 case iBigTri:
7216 82 tempitem.fam_type=0;
7217 82 break;
7218
7219 case iBombs:
7220 82 tempitem.fam_type=i_bomb;
7221 82 tempitem.power=4;
7222 82 tempitem.wpn=wBOMB;
7223 82 tempitem.wpn2=wBOOM;
7224 82 tempitem.misc1 = 50;
7225
7226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7227
7228 82 break;
7229
7230 case iSBomb:
7231 82 tempitem.fam_type=i_sbomb;
7232 82 tempitem.power=16;
7233 82 tempitem.wpn=wSBOMB;
7234 82 tempitem.wpn2=wSBOOM;
7235 82 tempitem.misc1 = 50;
7236
7237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7238
7239 82 break;
7240
7241 case iBook:
7242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7243 tempitem.wpn = wFIREMAGIC;
7244
7245 82 break;
7246
7247 case iSArrow:
7248 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7249 82 tempitem.power=4;
7250 82 tempitem.flags|=ITEM_GAMEDATA;
7251 82 tempitem.wpn=wSARROW;
7252 82 break;
7253
7254 case iGArrow:
7255 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7256 82 tempitem.power=8;
7257 82 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7258 82 tempitem.wpn=wGARROW;
7259 82 break;
7260
7261 case iBrang:
7262 82 tempitem.power=0;
7263 82 tempitem.wpn=wBRANG;
7264 82 tempitem.misc1=36;
7265 82 break;
7266
7267 case iMBrang:
7268 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7269 82 tempitem.power=0;
7270 82 tempitem.wpn=wMBRANG;
7271 82 break;
7272
7273 case iFBrang:
7274 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7275 82 tempitem.power=2;
7276 82 tempitem.wpn=wFBRANG;
7277 82 break;
7278
7279 case iBoots:
7280 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7281 82 tempitem.power=7;
7282 82 break;
7283
7284 case iWand:
7285 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7286 82 tempitem.power=2;
7287 82 tempitem.wpn=wWAND;
7288 82 tempitem.wpn3=wMAGIC;
7289 82 break;
7290
7291 case iBCandle:
7292 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7293 82 tempitem.power=1;
7294 82 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7295 82 tempitem.wpn3=wFIRE;
7296 82 break;
7297
7298 case iRCandle:
7299 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7300 82 tempitem.power=1;
7301 82 tempitem.wpn3=wFIRE;
7302 82 break;
7303
7304 case iSword:
7305 82 tempitem.power=1;
7306 82 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7307 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7308 82 tempitem.wpn2=wSWORDSLASH;
7309 82 break;
7310
7311 case iWSword:
7312 82 tempitem.power=2;
7313 82 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7314 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7315 82 tempitem.wpn2=wWSWORDSLASH;
7316 82 break;
7317
7318 case iMSword:
7319 82 tempitem.power=4;
7320 82 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7321 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7322 82 tempitem.wpn2=wMSWORDSLASH;
7323 82 break;
7324
7325 case iXSword:
7326 82 tempitem.power=8;
7327 82 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7328 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7329 82 tempitem.wpn2=wXSWORDSLASH;
7330 82 break;
7331
7332 case iDivineProtection:
7333 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7334 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7335 82 tempitem.wpn=wDIVINEPROTECTION1A;
7336 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7337 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7338 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7339 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7340 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7341 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7342 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7343 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7344 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7345 82 tempitem.misc1=512;
7346 82 tempitem.cost_amount[0]=64;
7347 82 break;
7348
7349 case iLens:
7350 82 tempitem.misc1=60;
7351 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7352 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7353 82 break;
7354
7355 case iArrow:
7356 82 tempitem.power=2;
7357 82 tempitem.wpn=wARROW;
7358 82 break;
7359
7360 case iHoverBoots:
7361 82 tempitem.misc1=45;
7362 82 tempitem.wpn=iwHover;
7363 82 break;
7364
7365 case iDivineFire:
7366 82 tempitem.power=8;
7367 82 tempitem.wpn=wDIVINEFIRE1A;
7368 82 tempitem.wpn2=wDIVINEFIRE1B;
7369 82 tempitem.wpn3=wDIVINEFIRES1A;
7370 82 tempitem.wpn4=wDIVINEFIRES1B;
7371 82 tempitem.misc1 = 32;
7372 82 tempitem.misc2 = 200;
7373 82 tempitem.cost_amount[0]=32;
7374 82 break;
7375
7376 case iDivineEscape:
7377 82 tempitem.cost_amount[0]=32;
7378 82 break;
7379
7380 case iHookshot:
7381 82 tempitem.power=0;
7382 82 tempitem.flags&=~ITEM_FLAG1;
7383 82 tempitem.wpn=wHSHEAD;
7384 82 tempitem.wpn2=wHSCHAIN_H;
7385 82 tempitem.wpn4=wHSHANDLE;
7386 82 tempitem.wpn3=wHSCHAIN_V;
7387 82 tempitem.misc1=50;
7388 82 tempitem.misc2=100;
7389 82 break;
7390
7391 case iLongshot:
7392 82 tempitem.power=0;
7393 82 tempitem.flags&=~ITEM_FLAG1;
7394 82 tempitem.wpn=wLSHEAD;
7395 82 tempitem.wpn2=wLSCHAIN_H;
7396 82 tempitem.wpn4=wLSHANDLE;
7397 82 tempitem.wpn3=wLSCHAIN_V;
7398 82 tempitem.misc1=99;
7399 82 tempitem.misc2=100;
7400 82 break;
7401
7402 case iHammer:
7403 82 tempitem.power=4;
7404 82 tempitem.wpn=wHAMMER;
7405 82 tempitem.wpn2=iwHammerSmack;
7406 82 break;
7407
7408 case iCByrna:
7409 82 tempitem.power=1;
7410 82 tempitem.wpn=wCBYRNA;
7411 82 tempitem.wpn2=wCBYRNASLASH;
7412 82 tempitem.wpn3=wCBYRNAORB;
7413 82 tempitem.misc1=4;
7414 82 tempitem.misc2=16;
7415 82 tempitem.misc3=1;
7416 82 tempitem.cost_amount[0]=1;
7417 82 break;
7418
7419 case iWhistle:
7420 82 tempitem.wpn=wWIND;
7421 82 tempitem.misc1=3;
7422 82 tempitem.flags|=ITEM_FLAG1;
7423 82 break;
7424
7425 case iBRing:
7426 82 tempitem.power=2;
7427 82 tempitem.misc1=spBLUE;
7428 82 break;
7429
7430 case iRRing:
7431 82 tempitem.power=4;
7432 82 tempitem.misc1=spRED;
7433 82 break;
7434
7435 case iGRing:
7436 82 tempitem.power=8;
7437 82 tempitem.misc1=spGOLD;
7438 82 break;
7439
7440 case iSpinScroll:
7441 82 tempitem.power = 2;
7442 82 tempitem.misc1 = 1;
7443 82 break;
7444
7445 case iL2SpinScroll:
7446 82 tempitem.family=itype_spinscroll2;
7447 82 tempitem.fam_type=1;
7448 82 tempitem.cost_amount[0]=8;
7449 82 tempitem.power=2;
7450 82 tempitem.misc1 = 20;
7451 82 break;
7452
7453 case iQuakeScroll:
7454 82 tempitem.misc1=0x10;
7455 82 tempitem.misc2=64;
7456 82 break;
7457
7458 case iL2QuakeScroll:
7459 82 tempitem.family=itype_quakescroll2;
7460 82 tempitem.fam_type=1;
7461 82 tempitem.power = 2;
7462 82 tempitem.misc1=0x20;
7463 82 tempitem.misc2=192;
7464 82 tempitem.cost_amount[0]=8;
7465 82 break;
7466
7467 case iChargeRing:
7468 82 tempitem.misc1=64;
7469 82 tempitem.misc2=128;
7470 82 break;
7471
7472 case iL2ChargeRing:
7473 82 tempitem.misc1=32;
7474 82 tempitem.misc2=64;
7475 82 break;
7476
7477 case iOldGlove:
7478 82 tempitem.flags |= ITEM_FLAG1;
7479
7480 //fallthrough
7481 case iBombBagL4:
7482 case iWalletL3:
7483 case iQuiverL4:
7484 case iBracelet:
7485 410 tempitem.power = 1;
7486 410 break;
7487
7488 case iL2Bracelet:
7489 82 tempitem.power = 2;
7490 82 break;
7491
7492 case iMKey:
7493 82 tempitem.power=0xFF;
7494 82 tempitem.flags |= ITEM_FLAG1;
7495 82 break;
7496 }
7497 20992 }
7498
7499
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 7)
7500 {
7501
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7502 {
7503 case iStoneAgony:
7504 case iStompBoots:
7505 case iPerilRing:
7506 case iWhimsicalRing:
7507 {
7508 328 reset_itembuf(&tempitem, i);
7509 328 strcpy(item_string[i],old_item_string[i]);
7510 328 break;
7511 }
7512 }
7513 20992 }
7514
7515
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 8) // May 2007: Some corrections.
7516 {
7517
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7518 {
7519 case iMShield:
7520 82 tempitem.misc1|=shFLAME;
7521 82 tempitem.misc2|=shFIREBALL|shMAGIC;
7522
7523
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7524 {
7525 tempitem.misc2 |= shSWORD;
7526 }
7527
7528 // fallthrough
7529 case iShield:
7530 164 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7531
7532 // fallthrough
7533 case iSShield:
7534 246 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7535
7536
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7537 {
7538 tempitem.misc2 |= shROCK;
7539 }
7540
7541 246 break;
7542
7543 case iWhispRing:
7544 82 tempitem.power=1;
7545 82 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7546 82 tempitem.misc1 = 3;
7547 82 break;
7548
7549 case iL2WhispRing:
7550 82 tempitem.power=0;
7551 82 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7552 82 tempitem.misc1 = 3;
7553 82 break;
7554
7555 case iL2Ladder:
7556 case iBow:
7557 case iCByrna:
7558 246 tempitem.power = 1;
7559 246 break;
7560 }
7561 20992 }
7562
7563
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 154624 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
175616 if(s_version < 9 && i==iClock)
7564 {
7565 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7566 82 }
7567
7568 //add the misc flag for bomb
7569
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 154624 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
175616 if(s_version < 10 && tempitem.family == itype_bomb)
7570 {
7571 82 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7572 82 }
7573
7574
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 154624 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
175616 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7575 {
7576 164 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7577 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7578 164 }
7579
7580
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 12) // June 2007: More Misc. attributes.
7581 {
7582
5/5
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 164 times.
✓ Branch 2 taken 20582 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7583 {
7584 case iFBrang:
7585 82 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7586
7587 //fallthrough
7588 case iMBrang:
7589 164 tempitem.misc3 |= shSWORD|shMAGIC;
7590
7591 //fallthrough
7592 case iHookshot:
7593 case iLongshot:
7594 //fallthrough
7595 328 tempitem.misc3 |= shFIREBALL;
7596
7597 case iBrang:
7598 410 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7599 410 break;
7600 }
7601
7602
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 164 times.
✓ Branch 10 taken 9629 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.family)
7603 {
7604 case itype_hoverboots:
7605 82 tempitem.usesound = WAV_ZN1HOVER;
7606 82 break;
7607
7608 case itype_wand:
7609 82 tempitem.usesound = WAV_WAND;
7610 82 break;
7611
7612 case itype_book:
7613 82 tempitem.usesound = WAV_FIRE;
7614 82 break;
7615
7616 case itype_arrow:
7617 246 tempitem.usesound = WAV_ARROW;
7618 246 break;
7619
7620 case itype_hookshot:
7621 164 tempitem.usesound = WAV_HOOKSHOT;
7622 164 break;
7623
7624 case itype_brang:
7625 246 tempitem.usesound = WAV_BRANG;
7626 246 break;
7627
7628 case itype_shield:
7629 246 tempitem.usesound = WAV_CHINK;
7630 246 break;
7631
7632 case itype_sword:
7633 9313 tempitem.usesound = WAV_SWORD;
7634 9313 break;
7635
7636 case itype_whistle:
7637 82 tempitem.usesound = WAV_WHISTLE;
7638 82 break;
7639
7640 case itype_hammer:
7641 82 tempitem.usesound = WAV_HAMMER;
7642 82 break;
7643
7644 case itype_divinefire:
7645 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7646 82 break;
7647
7648 case itype_divineescape:
7649 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7650 82 break;
7651
7652 case itype_divineprotection:
7653 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7654 82 break;
7655
7656 case itype_bomb:
7657 case itype_sbomb:
7658 case itype_quakescroll:
7659 case itype_quakescroll2:
7660 328 tempitem.usesound = WAV_BOMB;
7661 328 break;
7662
7663 case itype_spinscroll:
7664 case itype_spinscroll2:
7665 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7666 164 break;
7667 }
7668 20992 }
7669
7670
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 13) // July 2007
7671 {
7672
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7673 {
7674 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7675 82 tempitem.power = 1;
7676 82 tempitem.flags|=ITEM_FLAG1;
7677 82 }
7678
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7679 82 tempitem.flags|=ITEM_FLAG1;
7680
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7681 {
7682 82 tempitem.flags|=ITEM_FLAG1;
7683 82 tempitem.power = 2;
7684 82 }
7685 20992 }
7686
7687
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 14) // August 2007
7688 {
7689
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7690 {
7691 164 tempitem.usesound = WAV_SCALE;
7692
7693
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.fam_type)
7694 164 tempitem.misc3=50;
7695 164 }
7696
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7697 {
7698 164 tempitem.flags |= ITEM_GAINOLD;
7699 164 }
7700 20992 }
7701
7702
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 17) // November 2007
7703 {
7704
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7705 {
7706 tempitem.wpn3 = wFIRE;
7707 }
7708
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7709 {
7710 82 tempitem.flags|=ITEM_FLAG1;
7711 82 }
7712 20992 }
7713
7714
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 18) // New Year's Eve 2007
7715 {
7716
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7717 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7718
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7719 82 tempitem.misc1 = 768; // Frames until it goes
7720
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7721 {
7722
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & ITEM_GAMEDATA)
7723 {
7724 82 tempitem.misc2 = 1; // Cutscene 1
7725 82 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7726 82 }
7727 164 }
7728 20992 }
7729
7730
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 19) // January 2008
7731 {
7732
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7733 {
7734 82 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7735 82 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7736 82 }
7737 20992 }
7738
7739
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 20) // October 2008
7740 {
7741
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7742 {
7743 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7744 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7745 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7746 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7747 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7748 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7749 82 }
7750 20992 }
7751
7752
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 21) // November 2008
7753 {
7754
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // ITEM_SLASH
7755 {
7756 tempitem.flags &= ~0x0100;
7757
7758 if(tempitem.family == itype_sword ||
7759 tempitem.family == itype_wand ||
7760 tempitem.family == itype_candle ||
7761 tempitem.family == itype_cbyrna)
7762 {
7763 tempitem.flags |= ITEM_FLAG4;
7764 }
7765 }
7766 20992 }
7767
7768
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 22) // September 2009
7769 {
7770
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7771 {
7772 164 tempitem.misc3 = tempitem.power/2;
7773 164 }
7774 20992 }
7775
7776
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 23) // March 2011
7777 {
7778
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7779 82 tempitem.wpn5 = wFIRE;
7780
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7781 82 tempitem.wpn2 = wFIRE;
7782 20992 }
7783
7784 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7785 // whether it was or not, and a lot of existing quests depended on the
7786 // incorrect behavior.
7787
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 20992 times.
175616 if(s_version < 25) // January 2012
7788 {
7789
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7790 328 tempitem.flags |= 16;
7791
7792
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7793 82 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7794 20992 }
7795
7796
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7797 {
7798
60/60
✓ Branch 0 taken 17419 times.
✓ Branch 1 taken 801 times.
✓ Branch 2 taken 789 times.
✓ Branch 3 taken 572 times.
✓ Branch 4 taken 313 times.
✓ Branch 5 taken 267 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 585 times.
✓ Branch 8 taken 283 times.
✓ Branch 9 taken 849 times.
✓ Branch 10 taken 849 times.
✓ Branch 11 taken 526 times.
✓ Branch 12 taken 809 times.
✓ Branch 13 taken 530 times.
✓ Branch 14 taken 265 times.
✓ Branch 15 taken 530 times.
✓ Branch 16 taken 281 times.
✓ Branch 17 taken 265 times.
✓ Branch 18 taken 801 times.
✓ Branch 19 taken 267 times.
✓ Branch 20 taken 269 times.
✓ Branch 21 taken 532 times.
✓ Branch 22 taken 241 times.
✓ Branch 23 taken 267 times.
✓ Branch 24 taken 265 times.
✓ Branch 25 taken 265 times.
✓ Branch 26 taken 265 times.
✓ Branch 27 taken 281 times.
✓ Branch 28 taken 267 times.
✓ Branch 29 taken 267 times.
✓ Branch 30 taken 265 times.
✓ Branch 31 taken 269 times.
✓ Branch 32 taken 530 times.
✓ Branch 33 taken 1060 times.
✓ Branch 34 taken 755 times.
✓ Branch 35 taken 265 times.
✓ Branch 36 taken 515 times.
✓ Branch 37 taken 1060 times.
✓ Branch 38 taken 265 times.
✓ Branch 39 taken 265 times.
✓ Branch 40 taken 265 times.
✓ Branch 41 taken 265 times.
✓ Branch 42 taken 265 times.
✓ Branch 43 taken 532 times.
✓ Branch 44 taken 530 times.
✓ Branch 45 taken 265 times.
✓ Branch 46 taken 797 times.
✓ Branch 47 taken 799 times.
✓ Branch 48 taken 1068 times.
✓ Branch 49 taken 265 times.
✓ Branch 50 taken 265 times.
✓ Branch 51 taken 265 times.
✓ Branch 52 taken 265 times.
✓ Branch 53 taken 265 times.
✓ Branch 54 taken 291 times.
✓ Branch 55 taken 9393 times.
✓ Branch 56 taken 2726 times.
✓ Branch 57 taken 799 times.
✓ Branch 58 taken 3106 times.
✓ Branch 59 taken 10227 times.
68352 switch(tempitem.family)
7799 {
7800 case itype_sword:
7801 {
7802 17419 tempitem.flags &= ~(ITEM_FLAG5);
7803 17419 tempitem.misc3 = 0;
7804 17419 tempitem.misc4 = 0;
7805 17419 tempitem.misc5 = 0;
7806 17419 tempitem.misc6 = 0;
7807 17419 tempitem.misc7 = 0;
7808 17419 tempitem.misc8 = 0;
7809 17419 tempitem.misc9 = 0;
7810 17419 tempitem.misc10 = 0;
7811 17419 tempitem.wpn4 = 0;
7812 17419 tempitem.wpn5 = 0;
7813 17419 tempitem.wpn6 = 0;
7814 17419 tempitem.wpn7 = 0;
7815 17419 tempitem.wpn8 = 0;
7816 17419 tempitem.wpn9 = 0;
7817 17419 tempitem.wpn10 = 0;
7818 17419 break;
7819 }
7820 case itype_brang:
7821 {
7822 801 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7823 801 tempitem.misc2 = 0;
7824 801 tempitem.misc5 = 0;
7825 801 tempitem.misc6 = 0;
7826 801 tempitem.misc7 = 0;
7827 801 tempitem.misc8 = 0;
7828 801 tempitem.misc9 = 0;
7829 801 tempitem.misc10 = 0;
7830 801 tempitem.wpn4 = 0;
7831 801 tempitem.wpn5 = 0;
7832 801 tempitem.wpn6 = 0;
7833 801 tempitem.wpn7 = 0;
7834 801 tempitem.wpn8 = 0;
7835 801 tempitem.wpn9 = 0;
7836 801 tempitem.wpn10 = 0;
7837 801 break;
7838 }
7839 case itype_arrow:
7840 {
7841 789 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7842 789 tempitem.misc2 = 0;
7843 789 tempitem.misc3 = 0;
7844 789 tempitem.misc4 = 0;
7845 789 tempitem.misc5 = 0;
7846 789 tempitem.misc6 = 0;
7847 789 tempitem.misc7 = 0;
7848 789 tempitem.misc8 = 0;
7849 789 tempitem.misc9 = 0;
7850 789 tempitem.misc10 = 0;
7851 789 tempitem.wpn4 = 0;
7852 789 tempitem.wpn5 = 0;
7853 789 tempitem.wpn6 = 0;
7854 789 tempitem.wpn7 = 0;
7855 789 tempitem.wpn8 = 0;
7856 789 tempitem.wpn9 = 0;
7857 789 tempitem.wpn10 = 0;
7858 789 break;
7859 }
7860 case itype_candle:
7861 {
7862 572 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7863 572 tempitem.misc1 = 0;
7864 572 tempitem.misc2 = 0;
7865 572 tempitem.misc3 = 0;
7866 572 tempitem.misc4 = 0;
7867 572 tempitem.misc5 = 0;
7868 572 tempitem.misc6 = 0;
7869 572 tempitem.misc7 = 0;
7870 572 tempitem.misc8 = 0;
7871 572 tempitem.misc9 = 0;
7872 572 tempitem.misc10 = 0;
7873 572 tempitem.wpn4 = 0;
7874 572 tempitem.wpn5 = 0;
7875 572 tempitem.wpn6 = 0;
7876 572 tempitem.wpn7 = 0;
7877 572 tempitem.wpn8 = 0;
7878 572 tempitem.wpn9 = 0;
7879 572 tempitem.wpn10 = 0;
7880 572 break;
7881 }
7882 case itype_whistle:
7883 {
7884 313 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7885 313 tempitem.misc3 = 0;
7886 313 tempitem.misc4 = 0;
7887 313 tempitem.misc5 = 0;
7888 313 tempitem.misc6 = 0;
7889 313 tempitem.misc7 = 0;
7890 313 tempitem.misc8 = 0;
7891 313 tempitem.misc9 = 0;
7892 313 tempitem.misc10 = 0;
7893 313 tempitem.wpn2 = 0;
7894 313 tempitem.wpn3 = 0;
7895 313 tempitem.wpn4 = 0;
7896 313 tempitem.wpn5 = 0;
7897 313 tempitem.wpn6 = 0;
7898 313 tempitem.wpn7 = 0;
7899 313 tempitem.wpn8 = 0;
7900 313 tempitem.wpn9 = 0;
7901 313 tempitem.wpn10 = 0;
7902 313 break;
7903 }
7904 case itype_bait:
7905 {
7906 267 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7907 267 tempitem.misc2 = 0;
7908 267 tempitem.misc3 = 0;
7909 267 tempitem.misc4 = 0;
7910 267 tempitem.misc5 = 0;
7911 267 tempitem.misc6 = 0;
7912 267 tempitem.misc7 = 0;
7913 267 tempitem.misc8 = 0;
7914 267 tempitem.misc9 = 0;
7915 267 tempitem.misc10 = 0;
7916 267 tempitem.wpn2 = 0;
7917 267 tempitem.wpn3 = 0;
7918 267 tempitem.wpn4 = 0;
7919 267 tempitem.wpn5 = 0;
7920 267 tempitem.wpn6 = 0;
7921 267 tempitem.wpn7 = 0;
7922 267 tempitem.wpn8 = 0;
7923 267 tempitem.wpn9 = 0;
7924 267 tempitem.wpn10 = 0;
7925 267 break;
7926 }
7927 case itype_letter:
7928 {
7929 530 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7930 530 tempitem.misc1 = 0;
7931 530 tempitem.misc2 = 0;
7932 530 tempitem.misc3 = 0;
7933 530 tempitem.misc4 = 0;
7934 530 tempitem.misc5 = 0;
7935 530 tempitem.misc6 = 0;
7936 530 tempitem.misc7 = 0;
7937 530 tempitem.misc8 = 0;
7938 530 tempitem.misc9 = 0;
7939 530 tempitem.misc10 = 0;
7940 530 tempitem.wpn = 0;
7941 530 tempitem.wpn2 = 0;
7942 530 tempitem.wpn3 = 0;
7943 530 tempitem.wpn4 = 0;
7944 530 tempitem.wpn5 = 0;
7945 530 tempitem.wpn6 = 0;
7946 530 tempitem.wpn7 = 0;
7947 530 tempitem.wpn8 = 0;
7948 530 tempitem.wpn9 = 0;
7949 530 tempitem.wpn10 = 0;
7950 530 break;
7951 }
7952 case itype_potion:
7953 {
7954 585 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7955 585 tempitem.misc3 = 0;
7956 585 tempitem.misc4 = 0;
7957 585 tempitem.misc5 = 0;
7958 585 tempitem.misc6 = 0;
7959 585 tempitem.misc7 = 0;
7960 585 tempitem.misc8 = 0;
7961 585 tempitem.misc9 = 0;
7962 585 tempitem.misc10 = 0;
7963 585 tempitem.wpn = 0;
7964 585 tempitem.wpn2 = 0;
7965 585 tempitem.wpn3 = 0;
7966 585 tempitem.wpn4 = 0;
7967 585 tempitem.wpn5 = 0;
7968 585 tempitem.wpn6 = 0;
7969 585 tempitem.wpn7 = 0;
7970 585 tempitem.wpn8 = 0;
7971 585 tempitem.wpn9 = 0;
7972 585 tempitem.wpn10 = 0;
7973 585 break;
7974 }
7975 case itype_wand:
7976 {
7977 283 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7978 283 tempitem.misc1 = 0;
7979 283 tempitem.misc2 = 0;
7980 283 tempitem.misc3 = 0;
7981 283 tempitem.misc4 = 0;
7982 283 tempitem.misc5 = 0;
7983 283 tempitem.misc6 = 0;
7984 283 tempitem.misc7 = 0;
7985 283 tempitem.misc8 = 0;
7986 283 tempitem.misc9 = 0;
7987 283 tempitem.misc10 = 0;
7988 283 tempitem.wpn4 = 0;
7989 283 tempitem.wpn5 = 0;
7990 283 tempitem.wpn6 = 0;
7991 283 tempitem.wpn7 = 0;
7992 283 tempitem.wpn8 = 0;
7993 283 tempitem.wpn9 = 0;
7994 283 tempitem.wpn10 = 0;
7995 283 break;
7996 }
7997 case itype_ring:
7998 {
7999 849 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8000 849 tempitem.misc2 = 0;
8001 849 tempitem.misc3 = 0;
8002 849 tempitem.misc4 = 0;
8003 849 tempitem.misc5 = 0;
8004 849 tempitem.misc6 = 0;
8005 849 tempitem.misc7 = 0;
8006 849 tempitem.misc8 = 0;
8007 849 tempitem.misc9 = 0;
8008 849 tempitem.misc10 = 0;
8009 849 tempitem.wpn = 0;
8010 849 tempitem.wpn2 = 0;
8011 849 tempitem.wpn3 = 0;
8012 849 tempitem.wpn4 = 0;
8013 849 tempitem.wpn5 = 0;
8014 849 tempitem.wpn6 = 0;
8015 849 tempitem.wpn7 = 0;
8016 849 tempitem.wpn8 = 0;
8017 849 tempitem.wpn9 = 0;
8018 849 tempitem.wpn10 = 0;
8019 849 break;
8020 }
8021 case itype_wallet:
8022 {
8023 849 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8024 849 tempitem.misc3 = 0;
8025 849 tempitem.misc4 = 0;
8026 849 tempitem.misc5 = 0;
8027 849 tempitem.misc6 = 0;
8028 849 tempitem.misc7 = 0;
8029 849 tempitem.misc8 = 0;
8030 849 tempitem.misc9 = 0;
8031 849 tempitem.misc10 = 0;
8032 849 tempitem.wpn = 0;
8033 849 tempitem.wpn2 = 0;
8034 849 tempitem.wpn3 = 0;
8035 849 tempitem.wpn4 = 0;
8036 849 tempitem.wpn5 = 0;
8037 849 tempitem.wpn6 = 0;
8038 849 tempitem.wpn7 = 0;
8039 849 tempitem.wpn8 = 0;
8040 849 tempitem.wpn9 = 0;
8041 849 tempitem.wpn10 = 0;
8042 849 break;
8043 }
8044 case itype_amulet:
8045 {
8046 526 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8047 526 tempitem.misc1 = 0;
8048 526 tempitem.misc2 = 0;
8049 526 tempitem.misc3 = 0;
8050 526 tempitem.misc4 = 0;
8051 526 tempitem.misc5 = 0;
8052 526 tempitem.misc6 = 0;
8053 526 tempitem.misc7 = 0;
8054 526 tempitem.misc8 = 0;
8055 526 tempitem.misc9 = 0;
8056 526 tempitem.misc10 = 0;
8057 526 tempitem.wpn = 0;
8058 526 tempitem.wpn2 = 0;
8059 526 tempitem.wpn3 = 0;
8060 526 tempitem.wpn4 = 0;
8061 526 tempitem.wpn5 = 0;
8062 526 tempitem.wpn6 = 0;
8063 526 tempitem.wpn7 = 0;
8064 526 tempitem.wpn8 = 0;
8065 526 tempitem.wpn9 = 0;
8066 526 tempitem.wpn10 = 0;
8067 526 break;
8068 }
8069 case itype_shield:
8070 {
8071 809 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8072 809 tempitem.misc3 = 0;
8073 809 tempitem.misc4 = 0;
8074 809 tempitem.misc5 = 0;
8075 809 tempitem.misc6 = 0;
8076 809 tempitem.misc7 = 0;
8077 809 tempitem.misc8 = 0;
8078 809 tempitem.misc9 = 0;
8079 809 tempitem.misc10 = 0;
8080 809 tempitem.wpn = 0;
8081 809 tempitem.wpn2 = 0;
8082 809 tempitem.wpn3 = 0;
8083 809 tempitem.wpn4 = 0;
8084 809 tempitem.wpn5 = 0;
8085 809 tempitem.wpn6 = 0;
8086 809 tempitem.wpn7 = 0;
8087 809 tempitem.wpn8 = 0;
8088 809 tempitem.wpn9 = 0;
8089 809 tempitem.wpn10 = 0;
8090 809 break;
8091 }
8092 case itype_bow:
8093 {
8094 530 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8095 530 tempitem.misc1 = 0;
8096 530 tempitem.misc2 = 0;
8097 530 tempitem.misc3 = 0;
8098 530 tempitem.misc4 = 0;
8099 530 tempitem.misc5 = 0;
8100 530 tempitem.misc6 = 0;
8101 530 tempitem.misc7 = 0;
8102 530 tempitem.misc8 = 0;
8103 530 tempitem.misc9 = 0;
8104 530 tempitem.misc10 = 0;
8105 530 tempitem.wpn = 0;
8106 530 tempitem.wpn2 = 0;
8107 530 tempitem.wpn3 = 0;
8108 530 tempitem.wpn4 = 0;
8109 530 tempitem.wpn5 = 0;
8110 530 tempitem.wpn6 = 0;
8111 530 tempitem.wpn7 = 0;
8112 530 tempitem.wpn8 = 0;
8113 530 tempitem.wpn9 = 0;
8114 530 tempitem.wpn10 = 0;
8115 530 break;
8116 }
8117 case itype_raft:
8118 {
8119 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8120 265 tempitem.misc1 = 0;
8121 265 tempitem.misc2 = 0;
8122 265 tempitem.misc3 = 0;
8123 265 tempitem.misc4 = 0;
8124 265 tempitem.misc5 = 0;
8125 265 tempitem.misc6 = 0;
8126 265 tempitem.misc7 = 0;
8127 265 tempitem.misc8 = 0;
8128 265 tempitem.misc9 = 0;
8129 265 tempitem.misc10 = 0;
8130 265 tempitem.wpn = 0;
8131 265 tempitem.wpn2 = 0;
8132 265 tempitem.wpn3 = 0;
8133 265 tempitem.wpn4 = 0;
8134 265 tempitem.wpn5 = 0;
8135 265 tempitem.wpn6 = 0;
8136 265 tempitem.wpn7 = 0;
8137 265 tempitem.wpn8 = 0;
8138 265 tempitem.wpn9 = 0;
8139 265 tempitem.wpn10 = 0;
8140 265 break;
8141 }
8142 case itype_ladder:
8143 {
8144 530 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8145 530 tempitem.misc1 = 0;
8146 530 tempitem.misc2 = 0;
8147 530 tempitem.misc3 = 0;
8148 530 tempitem.misc4 = 0;
8149 530 tempitem.misc5 = 0;
8150 530 tempitem.misc6 = 0;
8151 530 tempitem.misc7 = 0;
8152 530 tempitem.misc8 = 0;
8153 530 tempitem.misc9 = 0;
8154 530 tempitem.misc10 = 0;
8155 530 tempitem.wpn = 0;
8156 530 tempitem.wpn2 = 0;
8157 530 tempitem.wpn3 = 0;
8158 530 tempitem.wpn4 = 0;
8159 530 tempitem.wpn5 = 0;
8160 530 tempitem.wpn6 = 0;
8161 530 tempitem.wpn7 = 0;
8162 530 tempitem.wpn8 = 0;
8163 530 tempitem.wpn9 = 0;
8164 530 tempitem.wpn10 = 0;
8165 530 break;
8166 }
8167 case itype_book:
8168 {
8169 281 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8170 281 tempitem.misc1 = 0;
8171 281 tempitem.misc2 = 0;
8172 281 tempitem.misc3 = 0;
8173 281 tempitem.misc4 = 0;
8174 281 tempitem.misc5 = 0;
8175 281 tempitem.misc6 = 0;
8176 281 tempitem.misc7 = 0;
8177 281 tempitem.misc8 = 0;
8178 281 tempitem.misc9 = 0;
8179 281 tempitem.misc10 = 0;
8180 281 tempitem.wpn3 = 0;
8181 281 tempitem.wpn4 = 0;
8182 281 tempitem.wpn5 = 0;
8183 281 tempitem.wpn6 = 0;
8184 281 tempitem.wpn7 = 0;
8185 281 tempitem.wpn8 = 0;
8186 281 tempitem.wpn9 = 0;
8187 281 tempitem.wpn10 = 0;
8188 281 break;
8189 }
8190 case itype_magickey:
8191 {
8192 265 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8193 265 tempitem.misc1 = 0;
8194 265 tempitem.misc2 = 0;
8195 265 tempitem.misc3 = 0;
8196 265 tempitem.misc4 = 0;
8197 265 tempitem.misc5 = 0;
8198 265 tempitem.misc6 = 0;
8199 265 tempitem.misc7 = 0;
8200 265 tempitem.misc8 = 0;
8201 265 tempitem.misc9 = 0;
8202 265 tempitem.misc10 = 0;
8203 265 tempitem.wpn = 0;
8204 265 tempitem.wpn2 = 0;
8205 265 tempitem.wpn3 = 0;
8206 265 tempitem.wpn4 = 0;
8207 265 tempitem.wpn5 = 0;
8208 265 tempitem.wpn6 = 0;
8209 265 tempitem.wpn7 = 0;
8210 265 tempitem.wpn8 = 0;
8211 265 tempitem.wpn9 = 0;
8212 265 tempitem.wpn10 = 0;
8213 265 break;
8214 }
8215 case itype_bracelet:
8216 {
8217 801 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8218 801 tempitem.misc1 = 0;
8219 801 tempitem.misc2 = 0;
8220 801 tempitem.misc3 = 0;
8221 801 tempitem.misc4 = 0;
8222 801 tempitem.misc5 = 0;
8223 801 tempitem.misc6 = 0;
8224 801 tempitem.misc7 = 0;
8225 801 tempitem.misc8 = 0;
8226 801 tempitem.misc9 = 0;
8227 801 tempitem.misc10 = 0;
8228 801 tempitem.wpn = 0;
8229 801 tempitem.wpn2 = 0;
8230 801 tempitem.wpn3 = 0;
8231 801 tempitem.wpn4 = 0;
8232 801 tempitem.wpn5 = 0;
8233 801 tempitem.wpn6 = 0;
8234 801 tempitem.wpn7 = 0;
8235 801 tempitem.wpn8 = 0;
8236 801 tempitem.wpn9 = 0;
8237 801 tempitem.wpn10 = 0;
8238 801 break;
8239 }
8240 case itype_flippers:
8241 {
8242 267 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8243 267 tempitem.misc1 = 0;
8244 267 tempitem.misc2 = 0;
8245 267 tempitem.misc3 = 0;
8246 267 tempitem.misc4 = 0;
8247 267 tempitem.misc5 = 0;
8248 267 tempitem.misc6 = 0;
8249 267 tempitem.misc7 = 0;
8250 267 tempitem.misc8 = 0;
8251 267 tempitem.misc9 = 0;
8252 267 tempitem.misc10 = 0;
8253 267 tempitem.wpn = 0;
8254 267 tempitem.wpn2 = 0;
8255 267 tempitem.wpn3 = 0;
8256 267 tempitem.wpn4 = 0;
8257 267 tempitem.wpn5 = 0;
8258 267 tempitem.wpn6 = 0;
8259 267 tempitem.wpn7 = 0;
8260 267 tempitem.wpn8 = 0;
8261 267 tempitem.wpn9 = 0;
8262 267 tempitem.wpn10 = 0;
8263 267 break;
8264 }
8265 case itype_boots:
8266 {
8267 269 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8268 269 tempitem.misc1 = 0;
8269 269 tempitem.misc2 = 0;
8270 269 tempitem.misc3 = 0;
8271 269 tempitem.misc4 = 0;
8272 269 tempitem.misc5 = 0;
8273 269 tempitem.misc6 = 0;
8274 269 tempitem.misc7 = 0;
8275 269 tempitem.misc8 = 0;
8276 269 tempitem.misc9 = 0;
8277 269 tempitem.misc10 = 0;
8278 269 tempitem.wpn = 0;
8279 269 tempitem.wpn2 = 0;
8280 269 tempitem.wpn3 = 0;
8281 269 tempitem.wpn4 = 0;
8282 269 tempitem.wpn5 = 0;
8283 269 tempitem.wpn6 = 0;
8284 269 tempitem.wpn7 = 0;
8285 269 tempitem.wpn8 = 0;
8286 269 tempitem.wpn9 = 0;
8287 269 tempitem.wpn10 = 0;
8288 269 break;
8289 }
8290 case itype_hookshot:
8291 {
8292 532 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8293 532 tempitem.misc5 = 0;
8294 532 tempitem.misc6 = 0;
8295 532 tempitem.misc7 = 0;
8296 532 tempitem.misc8 = 0;
8297 532 tempitem.misc9 = 0;
8298 532 tempitem.misc10 = 0;
8299 532 tempitem.wpn5 = 0;
8300 532 tempitem.wpn6 = 0;
8301 532 tempitem.wpn7 = 0;
8302 532 tempitem.wpn8 = 0;
8303 532 tempitem.wpn9 = 0;
8304 532 tempitem.wpn10 = 0;
8305 532 break;
8306 }
8307 case itype_lens:
8308 {
8309 241 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8310 241 tempitem.misc2 = 0;
8311 241 tempitem.misc3 = 0;
8312 241 tempitem.misc4 = 0;
8313 241 tempitem.misc5 = 0;
8314 241 tempitem.misc6 = 0;
8315 241 tempitem.misc7 = 0;
8316 241 tempitem.misc8 = 0;
8317 241 tempitem.misc9 = 0;
8318 241 tempitem.misc10 = 0;
8319 241 tempitem.wpn = 0;
8320 241 tempitem.wpn2 = 0;
8321 241 tempitem.wpn3 = 0;
8322 241 tempitem.wpn4 = 0;
8323 241 tempitem.wpn5 = 0;
8324 241 tempitem.wpn6 = 0;
8325 241 tempitem.wpn7 = 0;
8326 241 tempitem.wpn8 = 0;
8327 241 tempitem.wpn9 = 0;
8328 241 tempitem.wpn10 = 0;
8329 241 break;
8330 }
8331 case itype_hammer:
8332 {
8333 267 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8334 267 tempitem.misc1 = 0;
8335 267 tempitem.misc2 = 0;
8336 267 tempitem.misc3 = 0;
8337 267 tempitem.misc4 = 0;
8338 267 tempitem.misc5 = 0;
8339 267 tempitem.misc6 = 0;
8340 267 tempitem.misc7 = 0;
8341 267 tempitem.misc8 = 0;
8342 267 tempitem.misc9 = 0;
8343 267 tempitem.misc10 = 0;
8344 267 tempitem.wpn3 = 0;
8345 267 tempitem.wpn4 = 0;
8346 267 tempitem.wpn5 = 0;
8347 267 tempitem.wpn6 = 0;
8348 267 tempitem.wpn7 = 0;
8349 267 tempitem.wpn8 = 0;
8350 267 tempitem.wpn9 = 0;
8351 267 tempitem.wpn10 = 0;
8352 267 break;
8353 }
8354 case itype_divinefire:
8355 {
8356 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8357 265 tempitem.misc3 = 0;
8358 265 tempitem.misc4 = 0;
8359 265 tempitem.misc5 = 0;
8360 265 tempitem.misc6 = 0;
8361 265 tempitem.misc7 = 0;
8362 265 tempitem.misc8 = 0;
8363 265 tempitem.misc9 = 0;
8364 265 tempitem.misc10 = 0;
8365 265 tempitem.wpn6 = 0;
8366 265 tempitem.wpn7 = 0;
8367 265 tempitem.wpn8 = 0;
8368 265 tempitem.wpn9 = 0;
8369 265 tempitem.wpn10 = 0;
8370 265 break;
8371 }
8372 case itype_divineescape:
8373 {
8374 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8375 265 tempitem.misc2 = 0;
8376 265 tempitem.misc3 = 0;
8377 265 tempitem.misc4 = 0;
8378 265 tempitem.misc5 = 0;
8379 265 tempitem.misc6 = 0;
8380 265 tempitem.misc7 = 0;
8381 265 tempitem.misc8 = 0;
8382 265 tempitem.misc9 = 0;
8383 265 tempitem.misc10 = 0;
8384 265 tempitem.wpn = 0;
8385 265 tempitem.wpn2 = 0;
8386 265 tempitem.wpn3 = 0;
8387 265 tempitem.wpn4 = 0;
8388 265 tempitem.wpn5 = 0;
8389 265 tempitem.wpn6 = 0;
8390 265 tempitem.wpn7 = 0;
8391 265 tempitem.wpn8 = 0;
8392 265 tempitem.wpn9 = 0;
8393 265 tempitem.wpn10 = 0;
8394 265 break;
8395 }
8396 case itype_divineprotection:
8397 {
8398 265 tempitem.flags &= ~ (ITEM_FLAG5);
8399 265 tempitem.misc2 = 0;
8400 265 tempitem.misc3 = 0;
8401 265 tempitem.misc4 = 0;
8402 265 tempitem.misc5 = 0;
8403 265 tempitem.misc6 = 0;
8404 265 tempitem.misc7 = 0;
8405 265 tempitem.misc8 = 0;
8406 265 tempitem.misc9 = 0;
8407 265 tempitem.misc10 = 0;
8408 265 break;
8409 }
8410 case itype_bomb:
8411 {
8412 281 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8413 281 tempitem.misc4 = 0;
8414 281 tempitem.misc5 = 0;
8415 281 tempitem.misc6 = 0;
8416 281 tempitem.misc7 = 0;
8417 281 tempitem.misc8 = 0;
8418 281 tempitem.misc9 = 0;
8419 281 tempitem.misc10 = 0;
8420 281 tempitem.wpn3 = 0;
8421 281 tempitem.wpn4 = 0;
8422 281 tempitem.wpn5 = 0;
8423 281 tempitem.wpn6 = 0;
8424 281 tempitem.wpn7 = 0;
8425 281 tempitem.wpn8 = 0;
8426 281 tempitem.wpn9 = 0;
8427 281 tempitem.wpn10 = 0;
8428 281 break;
8429 }
8430 case itype_sbomb:
8431 {
8432 267 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8433 267 tempitem.misc4 = 0;
8434 267 tempitem.misc5 = 0;
8435 267 tempitem.misc6 = 0;
8436 267 tempitem.misc7 = 0;
8437 267 tempitem.misc8 = 0;
8438 267 tempitem.misc9 = 0;
8439 267 tempitem.misc10 = 0;
8440 267 tempitem.wpn3 = 0;
8441 267 tempitem.wpn4 = 0;
8442 267 tempitem.wpn5 = 0;
8443 267 tempitem.wpn6 = 0;
8444 267 tempitem.wpn7 = 0;
8445 267 tempitem.wpn8 = 0;
8446 267 tempitem.wpn9 = 0;
8447 267 tempitem.wpn10 = 0;
8448 267 break;
8449 }
8450 case itype_clock:
8451 {
8452 267 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8453 267 tempitem.misc2 = 0;
8454 267 tempitem.misc3 = 0;
8455 267 tempitem.misc4 = 0;
8456 267 tempitem.misc5 = 0;
8457 267 tempitem.misc6 = 0;
8458 267 tempitem.misc7 = 0;
8459 267 tempitem.misc8 = 0;
8460 267 tempitem.misc9 = 0;
8461 267 tempitem.misc10 = 0;
8462 267 tempitem.wpn = 0;
8463 267 tempitem.wpn2 = 0;
8464 267 tempitem.wpn3 = 0;
8465 267 tempitem.wpn4 = 0;
8466 267 tempitem.wpn5 = 0;
8467 267 tempitem.wpn6 = 0;
8468 267 tempitem.wpn7 = 0;
8469 267 tempitem.wpn8 = 0;
8470 267 tempitem.wpn9 = 0;
8471 267 tempitem.wpn10 = 0;
8472 267 break;
8473 }
8474 case itype_key:
8475 {
8476 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8477 265 tempitem.misc1 = 0;
8478 265 tempitem.misc2 = 0;
8479 265 tempitem.misc3 = 0;
8480 265 tempitem.misc4 = 0;
8481 265 tempitem.misc5 = 0;
8482 265 tempitem.misc6 = 0;
8483 265 tempitem.misc7 = 0;
8484 265 tempitem.misc8 = 0;
8485 265 tempitem.misc9 = 0;
8486 265 tempitem.misc10 = 0;
8487 265 tempitem.wpn = 0;
8488 265 tempitem.wpn2 = 0;
8489 265 tempitem.wpn3 = 0;
8490 265 tempitem.wpn4 = 0;
8491 265 tempitem.wpn5 = 0;
8492 265 tempitem.wpn6 = 0;
8493 265 tempitem.wpn7 = 0;
8494 265 tempitem.wpn8 = 0;
8495 265 tempitem.wpn9 = 0;
8496 265 tempitem.wpn10 = 0;
8497 265 break;
8498 }
8499 case itype_magiccontainer:
8500 {
8501 269 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8502 269 tempitem.misc1 = 0;
8503 269 tempitem.misc2 = 0;
8504 269 tempitem.misc3 = 0;
8505 269 tempitem.misc4 = 0;
8506 269 tempitem.misc5 = 0;
8507 269 tempitem.misc6 = 0;
8508 269 tempitem.misc7 = 0;
8509 269 tempitem.misc8 = 0;
8510 269 tempitem.misc9 = 0;
8511 269 tempitem.misc10 = 0;
8512 269 tempitem.wpn = 0;
8513 269 tempitem.wpn2 = 0;
8514 269 tempitem.wpn3 = 0;
8515 269 tempitem.wpn4 = 0;
8516 269 tempitem.wpn5 = 0;
8517 269 tempitem.wpn6 = 0;
8518 269 tempitem.wpn7 = 0;
8519 269 tempitem.wpn8 = 0;
8520 269 tempitem.wpn9 = 0;
8521 269 tempitem.wpn10 = 0;
8522 269 break;
8523 }
8524 case itype_triforcepiece:
8525 {
8526 530 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8527 530 tempitem.misc3 = 0;
8528 530 tempitem.misc4 = 0;
8529 530 tempitem.misc5 = 0;
8530 530 tempitem.misc6 = 0;
8531 530 tempitem.misc7 = 0;
8532 530 tempitem.misc8 = 0;
8533 530 tempitem.misc9 = 0;
8534 530 tempitem.misc10 = 0;
8535 530 tempitem.wpn = 0;
8536 530 tempitem.wpn2 = 0;
8537 530 tempitem.wpn3 = 0;
8538 530 tempitem.wpn4 = 0;
8539 530 tempitem.wpn5 = 0;
8540 530 tempitem.wpn6 = 0;
8541 530 tempitem.wpn7 = 0;
8542 530 tempitem.wpn8 = 0;
8543 530 tempitem.wpn9 = 0;
8544 530 tempitem.wpn10 = 0;
8545 530 break;
8546 }
8547 case itype_map: case itype_compass: case itype_bosskey:
8548 {
8549 799 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8550 799 tempitem.misc1 = 0;
8551 799 tempitem.misc2 = 0;
8552 799 tempitem.misc3 = 0;
8553 799 tempitem.misc4 = 0;
8554 799 tempitem.misc5 = 0;
8555 799 tempitem.misc6 = 0;
8556 799 tempitem.misc7 = 0;
8557 799 tempitem.misc8 = 0;
8558 799 tempitem.misc9 = 0;
8559 799 tempitem.misc10 = 0;
8560 799 tempitem.wpn = 0;
8561 799 tempitem.wpn2 = 0;
8562 799 tempitem.wpn3 = 0;
8563 799 tempitem.wpn4 = 0;
8564 799 tempitem.wpn5 = 0;
8565 799 tempitem.wpn6 = 0;
8566 799 tempitem.wpn7 = 0;
8567 799 tempitem.wpn8 = 0;
8568 799 tempitem.wpn9 = 0;
8569 799 tempitem.wpn10 = 0;
8570 799 break;
8571 }
8572 case itype_quiver:
8573 {
8574 1060 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8575 1060 tempitem.misc3 = 0;
8576 1060 tempitem.misc4 = 0;
8577 1060 tempitem.misc5 = 0;
8578 1060 tempitem.misc6 = 0;
8579 1060 tempitem.misc7 = 0;
8580 1060 tempitem.misc8 = 0;
8581 1060 tempitem.misc9 = 0;
8582 1060 tempitem.misc10 = 0;
8583 1060 tempitem.wpn = 0;
8584 1060 tempitem.wpn2 = 0;
8585 1060 tempitem.wpn3 = 0;
8586 1060 tempitem.wpn4 = 0;
8587 1060 tempitem.wpn5 = 0;
8588 1060 tempitem.wpn6 = 0;
8589 1060 tempitem.wpn7 = 0;
8590 1060 tempitem.wpn8 = 0;
8591 1060 tempitem.wpn9 = 0;
8592 1060 tempitem.wpn10 = 0;
8593 1060 break;
8594 }
8595 case itype_lkey:
8596 {
8597 755 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8598 755 tempitem.misc1 = 0;
8599 755 tempitem.misc2 = 0;
8600 755 tempitem.misc3 = 0;
8601 755 tempitem.misc4 = 0;
8602 755 tempitem.misc5 = 0;
8603 755 tempitem.misc6 = 0;
8604 755 tempitem.misc7 = 0;
8605 755 tempitem.misc8 = 0;
8606 755 tempitem.misc9 = 0;
8607 755 tempitem.misc10 = 0;
8608 755 tempitem.wpn = 0;
8609 755 tempitem.wpn2 = 0;
8610 755 tempitem.wpn3 = 0;
8611 755 tempitem.wpn4 = 0;
8612 755 tempitem.wpn5 = 0;
8613 755 tempitem.wpn6 = 0;
8614 755 tempitem.wpn7 = 0;
8615 755 tempitem.wpn8 = 0;
8616 755 tempitem.wpn9 = 0;
8617 755 tempitem.wpn10 = 0;
8618 755 break;
8619 }
8620 case itype_cbyrna:
8621 {
8622 265 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8623 265 tempitem.misc4 = 0;
8624 265 tempitem.misc5 = 0;
8625 265 tempitem.misc6 = 0;
8626 265 tempitem.misc7 = 0;
8627 265 tempitem.misc8 = 0;
8628 265 tempitem.misc9 = 0;
8629 265 tempitem.misc10 = 0;
8630 265 tempitem.wpn6 = 0;
8631 265 tempitem.wpn7 = 0;
8632 265 tempitem.wpn8 = 0;
8633 265 tempitem.wpn9 = 0;
8634 265 tempitem.wpn10 = 0;
8635 265 break;
8636 }
8637 case itype_rupee: case itype_arrowammo:
8638 {
8639 3106 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8640 3106 tempitem.misc1 = 0;
8641 3106 tempitem.misc2 = 0;
8642 3106 tempitem.misc3 = 0;
8643 3106 tempitem.misc4 = 0;
8644 3106 tempitem.misc5 = 0;
8645 3106 tempitem.misc6 = 0;
8646 3106 tempitem.misc7 = 0;
8647 3106 tempitem.misc8 = 0;
8648 3106 tempitem.misc9 = 0;
8649 3106 tempitem.misc10 = 0;
8650 3106 tempitem.wpn = 0;
8651 3106 tempitem.wpn2 = 0;
8652 3106 tempitem.wpn3 = 0;
8653 3106 tempitem.wpn4 = 0;
8654 3106 tempitem.wpn5 = 0;
8655 3106 tempitem.wpn6 = 0;
8656 3106 tempitem.wpn7 = 0;
8657 3106 tempitem.wpn8 = 0;
8658 3106 tempitem.wpn9 = 0;
8659 3106 tempitem.wpn10 = 0;
8660 3106 break;
8661 }
8662 case itype_fairy:
8663 {
8664 515 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8665 515 tempitem.misc4 = 0;
8666 515 tempitem.misc5 = 0;
8667 515 tempitem.misc6 = 0;
8668 515 tempitem.misc7 = 0;
8669 515 tempitem.misc8 = 0;
8670 515 tempitem.misc9 = 0;
8671 515 tempitem.misc10 = 0;
8672 515 tempitem.wpn = 0;
8673 515 tempitem.wpn2 = 0;
8674 515 tempitem.wpn3 = 0;
8675 515 tempitem.wpn4 = 0;
8676 515 tempitem.wpn5 = 0;
8677 515 tempitem.wpn6 = 0;
8678 515 tempitem.wpn7 = 0;
8679 515 tempitem.wpn8 = 0;
8680 515 tempitem.wpn9 = 0;
8681 515 tempitem.wpn10 = 0;
8682 515 break;
8683 }
8684 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8685 {
8686 2726 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8687 2726 tempitem.misc1 = 0;
8688 2726 tempitem.misc2 = 0;
8689 2726 tempitem.misc3 = 0;
8690 2726 tempitem.misc4 = 0;
8691 2726 tempitem.misc5 = 0;
8692 2726 tempitem.misc6 = 0;
8693 2726 tempitem.misc7 = 0;
8694 2726 tempitem.misc8 = 0;
8695 2726 tempitem.misc9 = 0;
8696 2726 tempitem.misc10 = 0;
8697 2726 tempitem.wpn = 0;
8698 2726 tempitem.wpn2 = 0;
8699 2726 tempitem.wpn3 = 0;
8700 2726 tempitem.wpn4 = 0;
8701 2726 tempitem.wpn5 = 0;
8702 2726 tempitem.wpn6 = 0;
8703 2726 tempitem.wpn7 = 0;
8704 2726 tempitem.wpn8 = 0;
8705 2726 tempitem.wpn9 = 0;
8706 2726 tempitem.wpn10 = 0;
8707 2726 break;
8708 }
8709 case itype_bombbag:
8710 {
8711 1060 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8712 1060 tempitem.misc3 = 0;
8713 1060 tempitem.misc4 = 0;
8714 1060 tempitem.misc5 = 0;
8715 1060 tempitem.misc6 = 0;
8716 1060 tempitem.misc7 = 0;
8717 1060 tempitem.misc8 = 0;
8718 1060 tempitem.misc9 = 0;
8719 1060 tempitem.misc10 = 0;
8720 1060 tempitem.wpn = 0;
8721 1060 tempitem.wpn2 = 0;
8722 1060 tempitem.wpn3 = 0;
8723 1060 tempitem.wpn4 = 0;
8724 1060 tempitem.wpn5 = 0;
8725 1060 tempitem.wpn6 = 0;
8726 1060 tempitem.wpn7 = 0;
8727 1060 tempitem.wpn8 = 0;
8728 1060 tempitem.wpn9 = 0;
8729 1060 tempitem.wpn10 = 0;
8730 1060 break;
8731 }
8732 case itype_rocs:
8733 {
8734 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8735 265 tempitem.misc1 = 0;
8736 265 tempitem.misc2 = 0;
8737 265 tempitem.misc3 = 0;
8738 265 tempitem.misc4 = 0;
8739 265 tempitem.misc5 = 0;
8740 265 tempitem.misc6 = 0;
8741 265 tempitem.misc7 = 0;
8742 265 tempitem.misc8 = 0;
8743 265 tempitem.misc9 = 0;
8744 265 tempitem.misc10 = 0;
8745 265 tempitem.wpn = 0;
8746 265 tempitem.wpn2 = 0;
8747 265 tempitem.wpn3 = 0;
8748 265 tempitem.wpn4 = 0;
8749 265 tempitem.wpn5 = 0;
8750 265 tempitem.wpn6 = 0;
8751 265 tempitem.wpn7 = 0;
8752 265 tempitem.wpn8 = 0;
8753 265 tempitem.wpn9 = 0;
8754 265 tempitem.wpn10 = 0;
8755 265 break;
8756 }
8757 case itype_hoverboots:
8758 {
8759 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8760 265 tempitem.misc2 = 0;
8761 265 tempitem.misc3 = 0;
8762 265 tempitem.misc4 = 0;
8763 265 tempitem.misc5 = 0;
8764 265 tempitem.misc6 = 0;
8765 265 tempitem.misc7 = 0;
8766 265 tempitem.misc8 = 0;
8767 265 tempitem.misc9 = 0;
8768 265 tempitem.misc10 = 0;
8769 265 tempitem.wpn2 = 0;
8770 265 tempitem.wpn3 = 0;
8771 265 tempitem.wpn4 = 0;
8772 265 tempitem.wpn5 = 0;
8773 265 tempitem.wpn6 = 0;
8774 265 tempitem.wpn7 = 0;
8775 265 tempitem.wpn8 = 0;
8776 265 tempitem.wpn9 = 0;
8777 265 tempitem.wpn10 = 0;
8778 265 break;
8779 }
8780 case itype_spinscroll:
8781 {
8782 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8783 265 tempitem.misc2 = 0;
8784 265 tempitem.misc3 = 0;
8785 265 tempitem.misc4 = 0;
8786 265 tempitem.misc5 = 0;
8787 265 tempitem.misc6 = 0;
8788 265 tempitem.misc7 = 0;
8789 265 tempitem.misc8 = 0;
8790 265 tempitem.misc9 = 0;
8791 265 tempitem.misc10 = 0;
8792 265 tempitem.wpn = 0;
8793 265 tempitem.wpn2 = 0;
8794 265 tempitem.wpn3 = 0;
8795 265 tempitem.wpn4 = 0;
8796 265 tempitem.wpn5 = 0;
8797 265 tempitem.wpn6 = 0;
8798 265 tempitem.wpn7 = 0;
8799 265 tempitem.wpn8 = 0;
8800 265 tempitem.wpn9 = 0;
8801 265 tempitem.wpn10 = 0;
8802 265 break;
8803 }
8804 case itype_crossscroll:
8805 {
8806 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8807 265 tempitem.misc1 = 0;
8808 265 tempitem.misc2 = 0;
8809 265 tempitem.misc3 = 0;
8810 265 tempitem.misc4 = 0;
8811 265 tempitem.misc5 = 0;
8812 265 tempitem.misc6 = 0;
8813 265 tempitem.misc7 = 0;
8814 265 tempitem.misc8 = 0;
8815 265 tempitem.misc9 = 0;
8816 265 tempitem.misc10 = 0;
8817 265 tempitem.wpn = 0;
8818 265 tempitem.wpn2 = 0;
8819 265 tempitem.wpn3 = 0;
8820 265 tempitem.wpn4 = 0;
8821 265 tempitem.wpn5 = 0;
8822 265 tempitem.wpn6 = 0;
8823 265 tempitem.wpn7 = 0;
8824 265 tempitem.wpn8 = 0;
8825 265 tempitem.wpn9 = 0;
8826 265 tempitem.wpn10 = 0;
8827 265 break;
8828 }
8829 case itype_quakescroll:
8830 {
8831 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8832 265 tempitem.misc3 = 0;
8833 265 tempitem.misc4 = 0;
8834 265 tempitem.misc5 = 0;
8835 265 tempitem.misc6 = 0;
8836 265 tempitem.misc7 = 0;
8837 265 tempitem.misc8 = 0;
8838 265 tempitem.misc9 = 0;
8839 265 tempitem.misc10 = 0;
8840 265 tempitem.wpn = 0;
8841 265 tempitem.wpn2 = 0;
8842 265 tempitem.wpn3 = 0;
8843 265 tempitem.wpn4 = 0;
8844 265 tempitem.wpn5 = 0;
8845 265 tempitem.wpn6 = 0;
8846 265 tempitem.wpn7 = 0;
8847 265 tempitem.wpn8 = 0;
8848 265 tempitem.wpn9 = 0;
8849 265 tempitem.wpn10 = 0;
8850 265 break;
8851 }
8852 case itype_whispring:
8853 {
8854 532 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8855 532 tempitem.misc2 = 0;
8856 532 tempitem.misc3 = 0;
8857 532 tempitem.misc4 = 0;
8858 532 tempitem.misc5 = 0;
8859 532 tempitem.misc6 = 0;
8860 532 tempitem.misc7 = 0;
8861 532 tempitem.misc8 = 0;
8862 532 tempitem.misc9 = 0;
8863 532 tempitem.misc10 = 0;
8864 532 tempitem.wpn = 0;
8865 532 tempitem.wpn2 = 0;
8866 532 tempitem.wpn3 = 0;
8867 532 tempitem.wpn4 = 0;
8868 532 tempitem.wpn5 = 0;
8869 532 tempitem.wpn6 = 0;
8870 532 tempitem.wpn7 = 0;
8871 532 tempitem.wpn8 = 0;
8872 532 tempitem.wpn9 = 0;
8873 532 tempitem.wpn10 = 0;
8874 532 break;
8875 }
8876 case itype_chargering:
8877 {
8878 530 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8879 530 tempitem.misc3 = 0;
8880 530 tempitem.misc4 = 0;
8881 530 tempitem.misc5 = 0;
8882 530 tempitem.misc6 = 0;
8883 530 tempitem.misc7 = 0;
8884 530 tempitem.misc8 = 0;
8885 530 tempitem.misc9 = 0;
8886 530 tempitem.misc10 = 0;
8887 530 tempitem.wpn = 0;
8888 530 tempitem.wpn2 = 0;
8889 530 tempitem.wpn3 = 0;
8890 530 tempitem.wpn4 = 0;
8891 530 tempitem.wpn5 = 0;
8892 530 tempitem.wpn6 = 0;
8893 530 tempitem.wpn7 = 0;
8894 530 tempitem.wpn8 = 0;
8895 530 tempitem.wpn9 = 0;
8896 530 tempitem.wpn10 = 0;
8897 530 break;
8898 }
8899 case itype_perilscroll:
8900 {
8901 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8902 265 tempitem.misc2 = 0;
8903 265 tempitem.misc3 = 0;
8904 265 tempitem.misc4 = 0;
8905 265 tempitem.misc5 = 0;
8906 265 tempitem.misc6 = 0;
8907 265 tempitem.misc7 = 0;
8908 265 tempitem.misc8 = 0;
8909 265 tempitem.misc9 = 0;
8910 265 tempitem.misc10 = 0;
8911 265 tempitem.wpn = 0;
8912 265 tempitem.wpn2 = 0;
8913 265 tempitem.wpn3 = 0;
8914 265 tempitem.wpn4 = 0;
8915 265 tempitem.wpn5 = 0;
8916 265 tempitem.wpn6 = 0;
8917 265 tempitem.wpn7 = 0;
8918 265 tempitem.wpn8 = 0;
8919 265 tempitem.wpn9 = 0;
8920 265 tempitem.wpn10 = 0;
8921 265 break;
8922 }
8923 case itype_wealthmedal:
8924 {
8925 797 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8926 797 tempitem.misc2 = 0;
8927 797 tempitem.misc3 = 0;
8928 797 tempitem.misc4 = 0;
8929 797 tempitem.misc5 = 0;
8930 797 tempitem.misc6 = 0;
8931 797 tempitem.misc7 = 0;
8932 797 tempitem.misc8 = 0;
8933 797 tempitem.misc9 = 0;
8934 797 tempitem.misc10 = 0;
8935 797 tempitem.wpn = 0;
8936 797 tempitem.wpn2 = 0;
8937 797 tempitem.wpn3 = 0;
8938 797 tempitem.wpn4 = 0;
8939 797 tempitem.wpn5 = 0;
8940 797 tempitem.wpn6 = 0;
8941 797 tempitem.wpn7 = 0;
8942 797 tempitem.wpn8 = 0;
8943 797 tempitem.wpn9 = 0;
8944 797 tempitem.wpn10 = 0;
8945 797 break;
8946 }
8947 case itype_heartring:
8948 {
8949 799 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8950 799 tempitem.misc3 = 0;
8951 799 tempitem.misc4 = 0;
8952 799 tempitem.misc5 = 0;
8953 799 tempitem.misc6 = 0;
8954 799 tempitem.misc7 = 0;
8955 799 tempitem.misc8 = 0;
8956 799 tempitem.misc9 = 0;
8957 799 tempitem.misc10 = 0;
8958 799 tempitem.wpn = 0;
8959 799 tempitem.wpn2 = 0;
8960 799 tempitem.wpn3 = 0;
8961 799 tempitem.wpn4 = 0;
8962 799 tempitem.wpn5 = 0;
8963 799 tempitem.wpn6 = 0;
8964 799 tempitem.wpn7 = 0;
8965 799 tempitem.wpn8 = 0;
8966 799 tempitem.wpn9 = 0;
8967 799 tempitem.wpn10 = 0;
8968 799 break;
8969 }
8970 case itype_magicring:
8971 {
8972 1068 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8973 1068 tempitem.misc3 = 0;
8974 1068 tempitem.misc4 = 0;
8975 1068 tempitem.misc5 = 0;
8976 1068 tempitem.misc6 = 0;
8977 1068 tempitem.misc7 = 0;
8978 1068 tempitem.misc8 = 0;
8979 1068 tempitem.misc9 = 0;
8980 1068 tempitem.misc10 = 0;
8981 1068 tempitem.wpn = 0;
8982 1068 tempitem.wpn2 = 0;
8983 1068 tempitem.wpn3 = 0;
8984 1068 tempitem.wpn4 = 0;
8985 1068 tempitem.wpn5 = 0;
8986 1068 tempitem.wpn6 = 0;
8987 1068 tempitem.wpn7 = 0;
8988 1068 tempitem.wpn8 = 0;
8989 1068 tempitem.wpn9 = 0;
8990 1068 tempitem.wpn10 = 0;
8991 1068 break;
8992 }
8993 case itype_spinscroll2:
8994 {
8995 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8996 265 tempitem.misc2 = 0;
8997 265 tempitem.misc3 = 0;
8998 265 tempitem.misc4 = 0;
8999 265 tempitem.misc5 = 0;
9000 265 tempitem.misc6 = 0;
9001 265 tempitem.misc7 = 0;
9002 265 tempitem.misc8 = 0;
9003 265 tempitem.misc9 = 0;
9004 265 tempitem.misc10 = 0;
9005 265 tempitem.wpn = 0;
9006 265 tempitem.wpn2 = 0;
9007 265 tempitem.wpn3 = 0;
9008 265 tempitem.wpn4 = 0;
9009 265 tempitem.wpn5 = 0;
9010 265 tempitem.wpn6 = 0;
9011 265 tempitem.wpn7 = 0;
9012 265 tempitem.wpn8 = 0;
9013 265 tempitem.wpn9 = 0;
9014 265 tempitem.wpn10 = 0;
9015 265 break;
9016 }
9017 case itype_quakescroll2:
9018 {
9019 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9020 265 tempitem.misc3 = 0;
9021 265 tempitem.misc4 = 0;
9022 265 tempitem.misc5 = 0;
9023 265 tempitem.misc6 = 0;
9024 265 tempitem.misc7 = 0;
9025 265 tempitem.misc8 = 0;
9026 265 tempitem.misc9 = 0;
9027 265 tempitem.misc10 = 0;
9028 265 tempitem.wpn = 0;
9029 265 tempitem.wpn2 = 0;
9030 265 tempitem.wpn3 = 0;
9031 265 tempitem.wpn4 = 0;
9032 265 tempitem.wpn5 = 0;
9033 265 tempitem.wpn6 = 0;
9034 265 tempitem.wpn7 = 0;
9035 265 tempitem.wpn8 = 0;
9036 265 tempitem.wpn9 = 0;
9037 265 tempitem.wpn10 = 0;
9038 265 break;
9039 }
9040 case itype_agony:
9041 {
9042 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9043 265 tempitem.misc2 = 0;
9044 265 tempitem.misc3 = 0;
9045 265 tempitem.misc4 = 0;
9046 265 tempitem.misc5 = 0;
9047 265 tempitem.misc6 = 0;
9048 265 tempitem.misc7 = 0;
9049 265 tempitem.misc8 = 0;
9050 265 tempitem.misc9 = 0;
9051 265 tempitem.misc10 = 0;
9052 265 tempitem.wpn = 0;
9053 265 tempitem.wpn2 = 0;
9054 265 tempitem.wpn3 = 0;
9055 265 tempitem.wpn4 = 0;
9056 265 tempitem.wpn5 = 0;
9057 265 tempitem.wpn6 = 0;
9058 265 tempitem.wpn7 = 0;
9059 265 tempitem.wpn8 = 0;
9060 265 tempitem.wpn9 = 0;
9061 265 tempitem.wpn10 = 0;
9062 265 break;
9063 }
9064 case itype_stompboots:
9065 {
9066 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9067 265 tempitem.misc1 = 0;
9068 265 tempitem.misc2 = 0;
9069 265 tempitem.misc3 = 0;
9070 265 tempitem.misc4 = 0;
9071 265 tempitem.misc5 = 0;
9072 265 tempitem.misc6 = 0;
9073 265 tempitem.misc7 = 0;
9074 265 tempitem.misc8 = 0;
9075 265 tempitem.misc9 = 0;
9076 265 tempitem.misc10 = 0;
9077 265 tempitem.wpn = 0;
9078 265 tempitem.wpn2 = 0;
9079 265 tempitem.wpn3 = 0;
9080 265 tempitem.wpn4 = 0;
9081 265 tempitem.wpn5 = 0;
9082 265 tempitem.wpn6 = 0;
9083 265 tempitem.wpn7 = 0;
9084 265 tempitem.wpn8 = 0;
9085 265 tempitem.wpn9 = 0;
9086 265 tempitem.wpn10 = 0;
9087 265 break;
9088 }
9089 case itype_whimsicalring:
9090 {
9091 265 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9092 265 tempitem.misc2 = 0;
9093 265 tempitem.misc3 = 0;
9094 265 tempitem.misc4 = 0;
9095 265 tempitem.misc5 = 0;
9096 265 tempitem.misc6 = 0;
9097 265 tempitem.misc7 = 0;
9098 265 tempitem.misc8 = 0;
9099 265 tempitem.misc9 = 0;
9100 265 tempitem.misc10 = 0;
9101 265 tempitem.wpn = 0;
9102 265 tempitem.wpn2 = 0;
9103 265 tempitem.wpn3 = 0;
9104 265 tempitem.wpn4 = 0;
9105 265 tempitem.wpn5 = 0;
9106 265 tempitem.wpn6 = 0;
9107 265 tempitem.wpn7 = 0;
9108 265 tempitem.wpn8 = 0;
9109 265 tempitem.wpn9 = 0;
9110 265 tempitem.wpn10 = 0;
9111 265 break;
9112 }
9113 case itype_perilring:
9114 {
9115 291 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9116 291 tempitem.misc2 = 0;
9117 291 tempitem.misc3 = 0;
9118 291 tempitem.misc4 = 0;
9119 291 tempitem.misc5 = 0;
9120 291 tempitem.misc6 = 0;
9121 291 tempitem.misc7 = 0;
9122 291 tempitem.misc8 = 0;
9123 291 tempitem.misc9 = 0;
9124 291 tempitem.misc10 = 0;
9125 291 tempitem.wpn = 0;
9126 291 tempitem.wpn2 = 0;
9127 291 tempitem.wpn3 = 0;
9128 291 tempitem.wpn4 = 0;
9129 291 tempitem.wpn5 = 0;
9130 291 tempitem.wpn6 = 0;
9131 291 tempitem.wpn7 = 0;
9132 291 tempitem.wpn8 = 0;
9133 291 tempitem.wpn9 = 0;
9134 291 tempitem.wpn10 = 0;
9135 291 break;
9136 }
9137 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9138 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9139 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9140 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9141 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9142 {
9143 9393 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9144 9393 tempitem.misc1 = 0;
9145 9393 tempitem.misc2 = 0;
9146 9393 tempitem.misc3 = 0;
9147 9393 tempitem.misc4 = 0;
9148 9393 tempitem.misc5 = 0;
9149 9393 tempitem.misc6 = 0;
9150 9393 tempitem.misc7 = 0;
9151 9393 tempitem.misc8 = 0;
9152 9393 tempitem.misc9 = 0;
9153 9393 tempitem.misc10 = 0;
9154 9393 tempitem.wpn = 0;
9155 9393 tempitem.wpn2 = 0;
9156 9393 tempitem.wpn3 = 0;
9157 9393 tempitem.wpn4 = 0;
9158 9393 tempitem.wpn5 = 0;
9159 9393 tempitem.wpn6 = 0;
9160 9393 tempitem.wpn7 = 0;
9161 9393 tempitem.wpn8 = 0;
9162 9393 tempitem.wpn9 = 0;
9163 9393 tempitem.wpn10 = 0;
9164 9393 break;
9165 }
9166 }
9167 68352 }
9168 //Port quest rules to items
9169
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version <= 31)
9170 {
9171
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 68071 times.
68352 if(tempitem.family == itype_bomb)
9172 {
9173
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 126 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9174 126 else tempitem.flags &= ~ ITEM_FLAG2;
9175 281 }
9176
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 67804 times.
68071 else if(tempitem.family == itype_sbomb)
9177 {
9178
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 110 times.
267 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9179 110 else tempitem.flags &= ~ ITEM_FLAG2;
9180 267 }
9181
9182
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 67003 times.
67804 else if(tempitem.family == itype_brang)
9183 {
9184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9185 801 else tempitem.flags &= ~ ITEM_FLAG4;
9186 801 }
9187
2/2
✓ Branch 0 taken 66720 times.
✓ Branch 1 taken 283 times.
67003 else if(tempitem.family == itype_wand)
9188 {
9189
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 268 times.
283 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9190 268 else tempitem.flags &= ~ ITEM_FLAG3;
9191 283 }
9192 68352 }
9193
9194 //Port quest rules to items
9195
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version <= 37)
9196 {
9197
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 68085 times.
68352 if(tempitem.family == itype_flippers)
9198 {
9199
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 189 times.
267 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9200 189 else tempitem.flags &= ~ ITEM_FLAG1;
9201 267 }
9202
2/2
✓ Branch 0 taken 50666 times.
✓ Branch 1 taken 17419 times.
68085 else if(tempitem.family == itype_sword)
9203 {
9204
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 16957 times.
17419 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9205 16957 else tempitem.flags &= ~ ITEM_FLAG5;
9206 17419 }
9207
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 50383 times.
50666 else if(tempitem.family == itype_wand)
9208 {
9209
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 273 times.
283 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9210 273 else tempitem.flags &= ~ ITEM_FLAG5;
9211 283 }
9212
4/4
✓ Branch 0 taken 50102 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 572 times.
✓ Branch 3 taken 49530 times.
50383 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9213 {
9214 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9215
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 478 times.
853 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9216 478 else tempitem.flags &= ~ ITEM_FLAG3;
9217 853 }
9218 68352 }
9219
9220
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 38)
9221 {
9222
4/4
✓ Branch 0 taken 67551 times.
✓ Branch 1 taken 801 times.
✓ Branch 2 taken 532 times.
✓ Branch 3 taken 67019 times.
68352 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9223 {
9224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1333 times.
1333 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9225 1333 else tempitem.flags &= ~ITEM_FLAG4;
9226
9227
2/2
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 681 times.
1333 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9228 681 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9229 1333 }
9230
2/2
✓ Branch 0 taken 66230 times.
✓ Branch 1 taken 789 times.
67019 else if(tempitem.family == itype_arrow)
9231 {
9232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 789 times.
789 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9233 789 else tempitem.flags &= ~ITEM_FLAG4;
9234
9235
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 405 times.
789 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9236 405 else tempitem.flags |= ITEM_FLAG2;
9237 789 }
9238 68352 }
9239
9240
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 39)
9241 {
9242
6/6
✓ Branch 0 taken 68087 times.
✓ Branch 1 taken 265 times.
✓ Branch 2 taken 67806 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 572 times.
✓ Branch 5 taken 67234 times.
68352 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9243 {
9244
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1102 times.
1118 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9245 1102 else tempitem.flags &= ~ITEM_FLAG5;
9246 1118 }
9247
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 66649 times.
67234 else if(tempitem.family == itype_potion)
9248 {
9249
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 423 times.
585 if(get_qr(qr_NONBUBBLEMEDICINE))
9250 {
9251 162 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9252 162 }
9253 else
9254 {
9255 423 tempitem.flags |= ITEM_FLAG3;
9256
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 310 times.
423 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9257 310 else tempitem.flags &= ~ITEM_FLAG4;
9258 }
9259 585 }
9260
2/2
✓ Branch 0 taken 66119 times.
✓ Branch 1 taken 530 times.
66649 else if(tempitem.family == itype_triforcepiece)
9261 {
9262
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 446 times.
530 if(get_qr(qr_NONBUBBLETRIFORCE))
9263 {
9264 84 tempitem.flags |= ITEM_FLAG3;
9265
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9266 28 else tempitem.flags &= ~ITEM_FLAG4;
9267 84 }
9268 else
9269 {
9270 446 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9271 }
9272 530 }
9273 68352 }
9274
9275
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 40)
9276 {
9277
4/4
✓ Branch 0 taken 67503 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 67212 times.
68352 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9278 {
9279
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 890 times.
1140 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9280 890 else tempitem.flags &= ~ITEM_FLAG1;
9281 1140 }
9282
8/8
✓ Branch 0 taken 66640 times.
✓ Branch 1 taken 572 times.
✓ Branch 2 taken 49221 times.
✓ Branch 3 taken 17419 times.
✓ Branch 4 taken 48938 times.
✓ Branch 5 taken 283 times.
✓ Branch 6 taken 265 times.
✓ Branch 7 taken 48673 times.
67212 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9283 {
9284
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18431 times.
18539 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9285 18431 else tempitem.flags &= ~ITEM_FLAG8;
9286 18539 }
9287
6/6
✓ Branch 0 taken 50933 times.
✓ Branch 1 taken 17419 times.
✓ Branch 2 taken 50650 times.
✓ Branch 3 taken 283 times.
✓ Branch 4 taken 267 times.
✓ Branch 5 taken 50383 times.
68352 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9288 {
9289
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 17865 times.
17969 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9290 17865 else tempitem.flags &= ~ITEM_FLAG7;
9291 17969 }
9292
2/2
✓ Branch 0 taken 50118 times.
✓ Branch 1 taken 265 times.
50383 else if(tempitem.family == itype_cbyrna)
9293 {
9294 265 tempitem.flags |= ITEM_FLAG7;
9295 265 }
9296 68352 }
9297
9298
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 41 )
9299 {
9300
2/2
✓ Branch 0 taken 50933 times.
✓ Branch 1 taken 17419 times.
68352 if(tempitem.family == itype_sword)
9301 {
9302
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 17327 times.
17419 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9303 17327 else tempitem.flags &= ~ITEM_FLAG9;
9304
9305
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 16991 times.
17419 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9306 16991 else tempitem.flags &= ~ITEM_FLAG10;
9307 17419 }
9308 68352 }
9309
9310
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 42 )
9311 {
9312
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 68069 times.
68352 if(tempitem.family == itype_wand)
9313 {
9314
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 268 times.
283 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9315 268 else tempitem.flags &= ~ITEM_FLAG3;
9316
9317 283 tempitem.flags &= ~ITEM_FLAG6;
9318 283 }
9319
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 67802 times.
68069 else if(tempitem.family == itype_hammer)
9320 {
9321 267 tempitem.flags &= ~ITEM_FLAG3;
9322 267 }
9323
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 67537 times.
67802 else if(tempitem.family == itype_cbyrna)
9324 {
9325 265 tempitem.flags |= ITEM_FLAG3;
9326
9327 265 tempitem.flags &= ~ITEM_FLAG6;
9328 265 }
9329
2/2
✓ Branch 0 taken 50118 times.
✓ Branch 1 taken 17419 times.
67537 else if(tempitem.family == itype_sword)
9330 {
9331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17419 times.
17419 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9332 17419 else tempitem.flags &= ~ITEM_FLAG6;
9333 17419 }
9334 68352 }
9335
9336
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 43 )
9337 {
9338
2/2
✓ Branch 0 taken 68039 times.
✓ Branch 1 taken 313 times.
68352 if(tempitem.family == itype_whistle)
9339 {
9340
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 309 times.
313 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9341 309 else tempitem.flags &= ~ITEM_FLAG3;
9342 313 }
9343 68352 }
9344
9345
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 45 )
9346 {
9347
2/2
✓ Branch 0 taken 68085 times.
✓ Branch 1 taken 267 times.
68352 if(tempitem.family == itype_flippers)
9348 {
9349 267 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9350 267 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9351 267 }
9352 68352 }
9353
9354
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 46 )
9355 {
9356
2/2
✓ Branch 0 taken 68087 times.
✓ Branch 1 taken 265 times.
68352 if(tempitem.family == itype_raft)
9357 {
9358 265 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9359 265 }
9360 68352 }
9361
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if ( s_version < 34 ) //! set the default counter for older quests.
9362 {
9363
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 68246 times.
68352 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9364 {
9365 106 tempitem.cost_counter[0] = 1;
9366 106 }
9367 else
9368 {
9369
2/2
✓ Branch 0 taken 41216 times.
✓ Branch 1 taken 27030 times.
68246 if(get_qr(qr_ENABLEMAGIC))
9370 41216 tempitem.cost_counter[0] = 4;
9371 else
9372 {
9373 27030 tempitem.cost_amount[0] = 0;
9374 27030 tempitem.cost_counter[0] = -1;
9375 }
9376 }
9377 68352 }
9378
9379
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if ( s_version < 35 ) //new Lens of Truth flags
9380 {
9381
2/2
✓ Branch 0 taken 68111 times.
✓ Branch 1 taken 241 times.
68352 if ( tempitem.family == itype_lens )
9382 {
9383
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 4 times.
241 if ( get_qr(qr_RAFTLENS) )
9384 {
9385 4 tempitem.flags |= ITEM_FLAG4;
9386 4 }
9387
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 166 times.
241 if ( get_qr(qr_LENSHINTS) )
9388 {
9389 166 tempitem.flags |= ITEM_FLAG1;
9390 166 }
9391
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 7 times.
241 if ( get_qr(qr_LENSSEESENEMIES) )
9392 {
9393 7 tempitem.flags |= ITEM_FLAG5;
9394 7 }
9395 241 }
9396 68352 }
9397
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9398 {
9399
2/2
✓ Branch 0 taken 546816 times.
✓ Branch 1 taken 68352 times.
615168 for ( int32_t q = 0; q < 8; q++ )
9400 {
9401 546816 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9402 546816 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9403 546816 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9404 546816 tempitem.sprite_initiald[q] = 0;
9405 546816 }
9406
2/2
✓ Branch 0 taken 136704 times.
✓ Branch 1 taken 68352 times.
205056 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9407 68352 tempitem.sprite_script = 0;
9408 68352 }
9409
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9410 {
9411 68352 tempitem.pickupflag = 0;
9412 68352 }
9413
9414
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 51 )
9415 {
9416
2/2
✓ Branch 0 taken 67780 times.
✓ Branch 1 taken 572 times.
68352 if( tempitem.family == itype_candle )
9417 {
9418 572 tempitem.misc4 = 50; //Step speed
9419 572 }
9420 68352 }
9421
9422
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if( s_version < 52 )
9423 {
9424
2/2
✓ Branch 0 taken 67543 times.
✓ Branch 1 taken 809 times.
68352 if( tempitem.family == itype_shield )
9425 809 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9426 68352 }
9427
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 68352 times.
175616 if(s_version < 53)
9428 {
9429
4/4
✓ Branch 0 taken 67015 times.
✓ Branch 1 taken 789 times.
✓ Branch 2 taken 281 times.
✓ Branch 3 taken 267 times.
68352 switch(tempitem.family)
9430 {
9431 case itype_arrow:
9432 789 tempitem.cost_counter[1] = crARROWS;
9433 789 tempitem.cost_amount[1] = 1;
9434 789 break;
9435 case itype_bomb:
9436 281 tempitem.cost_counter[1] = crBOMBS;
9437 281 tempitem.cost_amount[1] = 1;
9438 281 break;
9439 case itype_sbomb:
9440 267 tempitem.cost_counter[1] = crSBOMBS;
9441 267 tempitem.cost_amount[1] = 1;
9442 267 break;
9443 default:
9444 67015 tempitem.cost_counter[1] = crNONE;
9445 67015 tempitem.cost_amount[1] = 0;
9446 67015 }
9447 68352 tempitem.magiccosttimer[1] = 0;
9448 68352 }
9449
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 71168 times.
175616 if( s_version < 54 )
9450 {
9451
2/2
✓ Branch 0 taken 70888 times.
✓ Branch 1 taken 280 times.
71168 if( tempitem.family == itype_flippers )
9452 280 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9453 71168 }
9454
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 71168 times.
175616 if(s_version < 55)
9455 {
9456
3/3
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 552 times.
✓ Branch 2 taken 70064 times.
71168 switch(tempitem.family)
9457 {
9458 case itype_spinscroll:
9459 case itype_quakescroll:
9460 552 tempitem.usesound2 = WAV_ZN1CHARGE;
9461 552 break;
9462 case itype_spinscroll2:
9463 case itype_quakescroll2:
9464 552 tempitem.usesound2 = WAV_ZN1CHARGE2;
9465 552 break;
9466 }
9467 71168 }
9468
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 71168 times.
175616 if(s_version < 56)
9469 {
9470
4/4
✓ Branch 0 taken 70002 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 292 times.
71168 switch(tempitem.family)
9471 {
9472 case itype_divinefire:
9473
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 11 times.
276 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9474
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 194 times.
276 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9475 276 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9476 276 break;
9477 case itype_candle:
9478
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 300 times.
598 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9479 598 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9480 598 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9481 598 break;
9482 case itype_book:
9483 292 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9484 292 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9485 292 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9486 292 break;
9487 }
9488 71168 }
9489
9490
2/2
✓ Branch 0 taken 164628 times.
✓ Branch 1 taken 10988 times.
175616 if(tempitem.fam_type==0) // Always do this
9491 10988 tempitem.fam_type=1;
9492
9493 175616 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9494 175616 }
9495
9496 686 return 0;
9497 687 }
9498
9499 static bool did_init_def_items = false;
9500 351098 void init_def_items()
9501 {
9502
2/2
✓ Branch 0 taken 350790 times.
✓ Branch 1 taken 308 times.
351098 if(did_init_def_items) return;
9503 308 did_init_def_items = true;
9504 308 default_items[3].cost_counter[1] = crBOMBS;
9505 308 default_items[13].cost_counter[1] = crARROWS;
9506 308 default_items[14].cost_counter[1] = crARROWS;
9507 308 default_items[48].cost_counter[1] = crSBOMBS;
9508 308 default_items[57].cost_counter[1] = crARROWS;
9509 351098 }
9510 351098 void reset_itembuf(itemdata *item, int32_t id)
9511 {
9512 351098 init_def_items();
9513
2/2
✓ Branch 0 taken 149725 times.
✓ Branch 1 taken 201373 times.
351098 if(id<iLast)
9514 {
9515 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9516 201373 word tile = item->tile;
9517 201373 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9518 201373 int32_t ltm = item->ltm;
9519
9520 201373 memcpy(item,&default_items[id],sizeof(itemdata));
9521 201373 item->tile = tile;
9522 201373 item->misc_flags = miscs;
9523 201373 item->csets = cset;
9524 201373 item->frames = frames;
9525 201373 item->speed = speed;
9526 201373 item->delay = delay;
9527 201373 item->ltm = ltm;
9528 201373 }
9529 351098 }
9530
9531 88320 void reset_itemname(int32_t id)
9532 {
9533 88320 sprintf(item_string[id],"zz%03d",id);
9534
9535
2/2
✓ Branch 0 taken 38985 times.
✓ Branch 1 taken 49335 times.
88320 if(id < iLast)
9536 49335 strcpy(item_string[id],old_item_string[id]);
9537 88320 }
9538
9539 687 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9540 {
9541
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9542
9543 687 word weapons_to_read=MAXWPNS;
9544 int32_t dummy;
9545 byte padding;
9546 wpndata tempweapon;
9547 687 word s_version=0, s_cversion=0;
9548
9549
9550
2/2
✓ Branch 0 taken 681 times.
✓ Branch 1 taken 6 times.
687 if(Header->zelda_version < 0x186)
9551 {
9552 6 weapons_to_read=64;
9553 6 }
9554
9555
2/2
✓ Branch 0 taken 681 times.
✓ Branch 1 taken 6 times.
687 if(Header->zelda_version < 0x185)
9556 {
9557 6 weapons_to_read=32;
9558 6 }
9559
9560
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(Header->zelda_version > 0x192)
9561 {
9562 663 weapons_to_read=0;
9563
9564 //section version info
9565
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
9566 {
9567 return qe_invalid;
9568 }
9569
9570 663 FFCore.quest_format[vWeaponSprites] = s_version;
9571
9572 //al_trace("Weapons version %d\n", s_version);
9573
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_cversion,f))
9574 {
9575 return qe_invalid;
9576 }
9577
9578 //section size
9579
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
9580 {
9581 return qe_invalid;
9582 }
9583
9584 //finally... section data
9585
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&weapons_to_read,f))
9586 {
9587 return qe_invalid;
9588 }
9589
9590
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9591 {
9592 return qe_invalid;
9593 }
9594 663 }
9595
9596
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 83 times.
687 if(s_version>2)
9597 {
9598
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 604 times.
155228 for(int32_t i=0; i<weapons_to_read; i++)
9599 {
9600 char tempname[64];
9601
9602
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if(!pfread(tempname, 64, f))
9603 {
9604 return qe_invalid;
9605 }
9606
9607 154624 weapon_string[i][0] = '\0';
9608 154624 strncat(weapon_string[i], tempname, 64 - 1);
9609 154624 }
9610
9611
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(s_version<4)
9612 {
9613 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9614 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9615 }
9616
9617
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(s_version<5)
9618 {
9619 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9620 }
9621
9622 /*
9623 if (s_version<6)
9624 {
9625 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9626 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9627 }
9628 */
9629 604 }
9630
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9631 {
9632
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9633 20992 reset_weaponname(i);
9634 82 }
9635
9636
2/2
✓ Branch 0 taken 163436 times.
✓ Branch 1 taken 687 times.
164123 for(int32_t i=0; i<weapons_to_read; i++)
9637 {
9638 163436 word oldtile = 0;
9639
2/2
✓ Branch 0 taken 105984 times.
✓ Branch 1 taken 57452 times.
163436 if (s_version < 8)
9640 {
9641
1/2
✓ Branch 0 taken 57452 times.
✗ Branch 1 not taken.
57452 if (!p_igetw(&oldtile, f))
9642 return qe_invalid;
9643 57452 }
9644
9645
1/2
✓ Branch 0 taken 163436 times.
✗ Branch 1 not taken.
163436 if(!p_getc(&tempweapon.misc,f))
9646 {
9647 return qe_invalid;
9648 }
9649
9650
1/2
✓ Branch 0 taken 163436 times.
✗ Branch 1 not taken.
163436 if(!p_getc(&tempweapon.csets,f))
9651 {
9652 return qe_invalid;
9653 }
9654
9655
1/2
✓ Branch 0 taken 163436 times.
✗ Branch 1 not taken.
163436 if(!p_getc(&tempweapon.frames,f))
9656 {
9657 return qe_invalid;
9658 }
9659
9660
1/2
✓ Branch 0 taken 163436 times.
✗ Branch 1 not taken.
163436 if(!p_getc(&tempweapon.speed,f))
9661 {
9662 return qe_invalid;
9663 }
9664
9665
1/2
✓ Branch 0 taken 163436 times.
✗ Branch 1 not taken.
163436 if(!p_getc(&tempweapon.type,f))
9666 {
9667 return qe_invalid;
9668 }
9669
9670
2/2
✓ Branch 0 taken 56172 times.
✓ Branch 1 taken 107264 times.
163436 if ( s_version >= 7 )
9671 {
9672
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetw(&tempweapon.script,f))
9673 {
9674 return qe_invalid;
9675 }
9676
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if(!p_igetl(&tempweapon.tile,f))
9677 {
9678 return qe_invalid;
9679 }
9680 107264 }
9681
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 56172 times.
163436 if ( s_version < 7 )
9682 {
9683 56172 tempweapon.tile = oldtile;
9684 56172 }
9685
9686
2/2
✓ Branch 0 taken 158636 times.
✓ Branch 1 taken 4800 times.
163436 if(Header->zelda_version < 0x193)
9687 {
9688
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9689 {
9690 return qe_invalid;
9691 }
9692 4800 }
9693
9694
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 8812 times.
163436 if(s_version < 6)
9695 {
9696
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9697 {
9698 18 tempweapon.misc |= WF_BEHIND;
9699 18 }
9700 else
9701 8794 tempweapon.misc &= ~WF_BEHIND;
9702 8812 }
9703
9704
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 163180 times.
163436 if (!should_skip)
9705 163180 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9706 163436 }
9707
9708
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if (should_skip)
9709 1 return 0;
9710
9711
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<2)
9712 {
9713 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9714 82 }
9715
9716
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(s_version<5)
9717 {
9718 82 wpnsbuf[iwQuarterHearts].tile=1;
9719 82 wpnsbuf[iwQuarterHearts].csets=1;
9720 82 }
9721
9722
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 if(Header->zelda_version < 0x176)
9723 {
9724 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9725 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9726 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9727 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9728 }
9729
9730
3/4
✓ Branch 0 taken 668 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
691 if((Header->zelda_version < 0x192)||
9731
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 663 times.
668 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9732 {
9733 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9734 18 }
9735
9736
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 if((Header->zelda_version < 0x210))
9737 {
9738 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9739 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9740 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9741 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9742 23 }
9743
9744 686 return 0;
9745 687 }
9746
9747 686 void init_guys(int32_t guyversion)
9748 {
9749
2/2
✓ Branch 0 taken 351232 times.
✓ Branch 1 taken 686 times.
351918 for(int32_t i=0; i<MAXGUYS; i++)
9750 {
9751 351232 guysbuf[i] = default_guys[0];
9752 351232 }
9753
9754
2/2
✓ Branch 0 taken 121422 times.
✓ Branch 1 taken 686 times.
122108 for(int32_t i=0; i<OLDMAXGUYS; i++)
9755 {
9756 121422 guysbuf[i] = default_guys[i];
9757
2/2
✓ Branch 0 taken 120050 times.
✓ Branch 1 taken 1372 times.
121422 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9758 121422 guysbuf[i].spr_death = iwDeath;
9759 121422 guysbuf[i].spr_spawn = iwSpawn;
9760 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9761
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 106908 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
121422 if(guyversion<=3 && i==ePATRABS)
9762 {
9763 82 guysbuf[i].bosspal=spDIG;
9764 82 guysbuf[i].cset=14;
9765 82 guysbuf[i].misc9=14;
9766 82 }
9767
9768
2/2
✓ Branch 0 taken 106908 times.
✓ Branch 1 taken 14514 times.
121422 if(guyversion<=3)
9769 {
9770 // Rope/Ghini Flash rules
9771
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9772 {
9773
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9774 {
9775 59 guysbuf[i].flags2 &= ~guy_flashing;
9776 59 }
9777 10443 }
9778
9779
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9780 {
9781
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9782 {
9783 72 guysbuf[i].flags2 &= ~guy_flashing;
9784 72 }
9785 2124 }
9786
9787
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9788 {
9789
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9790 {
9791 4 guysbuf[i].flags2 |= guy_blinking;
9792 4 }
9793
9794
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9795 {
9796 38 guysbuf[i].flags2 |= guy_transparent;
9797 38 }
9798 82 }
9799 14514 }
9800
9801 // Darknut fix
9802
10/10
✓ Branch 0 taken 120736 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 120050 times.
✓ Branch 3 taken 686 times.
✓ Branch 4 taken 119364 times.
✓ Branch 5 taken 686 times.
✓ Branch 6 taken 118678 times.
✓ Branch 7 taken 686 times.
✓ Branch 8 taken 686 times.
✓ Branch 9 taken 117992 times.
121422 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9803 {
9804
2/2
✓ Branch 0 taken 3070 times.
✓ Branch 1 taken 360 times.
3430 if(get_qr(qr_NEWENEMYTILES))
9805 {
9806 3070 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9807 3070 guysbuf[i].s_width=guysbuf[i].e_width;
9808 3070 guysbuf[i].s_height=guysbuf[i].e_height;
9809 3070 }
9810 360 else guysbuf[i].s_tile=860;
9811
9812
2/2
✓ Branch 0 taken 3020 times.
✓ Branch 1 taken 410 times.
3430 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9813 {
9814 410 guysbuf[i].flags |= guy_bkshield;
9815 410 }
9816 3430 }
9817
9818
4/4
✓ Branch 0 taken 120736 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 121372 times.
✓ Branch 3 taken 50 times.
121422 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9819 {
9820 50 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9821 50 }
9822 121422 }
9823 686 }
9824
9825 20992 void reset_weaponname(int32_t i)
9826 {
9827
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9828 {
9829 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9830 7216 }
9831 else
9832 13776 sprintf(weapon_string[i],"zz%03d",i);
9833 20992 }
9834
9835 686 void init_item_drop_sets()
9836 {
9837
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9838 {
9839 // item_drop_sets[i] = default_item_drop_sets[0];
9840 175616 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9841 175616 }
9842
9843
2/2
✓ Branch 0 taken 8918 times.
✓ Branch 1 taken 686 times.
9604 for(int32_t i=0; i<isMAX; i++)
9844 {
9845 8918 item_drop_sets[i] = default_item_drop_sets[i];
9846
9847 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9848
2/2
✓ Branch 0 taken 89180 times.
✓ Branch 1 taken 8918 times.
98098 for(int32_t j=0; j<10; ++j)
9849 {
9850 89180 int32_t it = item_drop_sets[i].item[j];
9851
9852
3/4
✓ Branch 0 taken 62928 times.
✓ Branch 1 taken 26252 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4074 times.
89180 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9853
2/2
✓ Branch 0 taken 4074 times.
✓ Branch 1 taken 58854 times.
62928 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9854 {
9855 4074 item_drop_sets[i].chance[j+1]=0;
9856 4074 }
9857
4/4
✓ Branch 0 taken 2744 times.
✓ Branch 1 taken 82362 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 2600 times.
85106 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9858 {
9859 144 item_drop_sets[i].chance[j+1]=0;
9860 144 }
9861
9862 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9863
2/2
✓ Branch 0 taken 89156 times.
✓ Branch 1 taken 24 times.
89180 if(itemsbuf[it].family == itype_misc)
9864 {
9865 // If a non-gameplay item was selected, then item drop was aborted.
9866 // Reflect this by increasing the 'Nothing' chance accordingly.
9867 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9868 24 item_drop_sets[i].chance[j+1]=0;
9869 24 }
9870 89180 }
9871 8918 }
9872 686 }
9873
9874 686 void init_favorites()
9875 {
9876
2/2
✓ Branch 0 taken 864360 times.
✓ Branch 1 taken 686 times.
865046 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9877 {
9878 864360 favorite_combos[i]=-1;
9879 864360 }
9880 686 }
9881
9882 const char *ctype_name[cMAX]=
9883 {
9884 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9885 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9886 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9887 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9888 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9889 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9890 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9891 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9892 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9893 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9894 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9895 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9896 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9897 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9898 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9899 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9900 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9901 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9902 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9903 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9904 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9905 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9906 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9907 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9908 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9909 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9910 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9911 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9912
9913 };
9914
9915 958 int32_t init_combo_classes()
9916 {
9917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 958 times.
958 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9918
2/2
✓ Branch 0 taken 175314 times.
✓ Branch 1 taken 958 times.
176272 for(int32_t i=0; i<cMAX; i++)
9919 {
9920 175314 combo_class_buf[i] = default_combo_classes[i];
9921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175314 times.
175314 if ( char const* nm = zi->getComboTypeName(i) )
9922 {
9923 175314 size_t len = strlen(nm);
9924
2/2
✓ Branch 0 taken 11220096 times.
✓ Branch 1 taken 175314 times.
11395410 for ( size_t q = 0; q < 64; q++ )
9925 {
9926
2/2
✓ Branch 0 taken 2568398 times.
✓ Branch 1 taken 8651698 times.
11220096 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9927 11220096 }
9928 175314 }
9929 175314 }
9930
9931 958 return 0;
9932 }
9933
9934 290 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9935 {
9936
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 244 times.
290 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 if (should_skip) return 0;
9938
9939
1/2
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
290 assert(v_herosprites < 6);
9940 //these are here to bypass compiler warnings about unused arguments
9941 290 cv_herosprites=cv_herosprites;
9942
9943 290 zinit.hero_swim_speed=67; //default
9944 290 setupherotiles(zinit.heroAnimationStyle);
9945 290 setupherodefenses();
9946 290 setupherooffsets();
9947
9948
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 185 times.
290 if(v_herosprites>=0)
9949 {
9950 word tile, tile2;
9951 byte flip, extend, dummy_byte;
9952
9953
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
9954 {
9955
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
9956 {
9957 return qe_invalid;
9958 }
9959
9960
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
9961 {
9962 return qe_invalid;
9963 }
9964
9965
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
9966 {
9967 return qe_invalid;
9968 }
9969
9970 740 walkspr[i][spr_tile]=(int32_t)tile;
9971 740 walkspr[i][spr_flip]=(int32_t)flip;
9972 740 walkspr[i][spr_extend]=(int32_t)extend;
9973 740 }
9974
9975
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
9976 {
9977
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
9978 {
9979 return qe_invalid;
9980 }
9981
9982
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
9983 {
9984 return qe_invalid;
9985 }
9986
9987
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
9988 {
9989 return qe_invalid;
9990 }
9991
9992 740 stabspr[i][spr_tile]=(int32_t)tile;
9993 740 stabspr[i][spr_flip]=(int32_t)flip;
9994 740 stabspr[i][spr_extend]=(int32_t)extend;
9995 740 }
9996
9997
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
9998 {
9999
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10000 {
10001 return qe_invalid;
10002 }
10003
10004
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10005 {
10006 return qe_invalid;
10007 }
10008
10009
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10010 {
10011 return qe_invalid;
10012 }
10013
10014 740 slashspr[i][spr_tile]=(int32_t)tile;
10015 740 slashspr[i][spr_flip]=(int32_t)flip;
10016 740 slashspr[i][spr_extend]=(int32_t)extend;
10017 740 }
10018
10019
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
10020 {
10021
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10022 {
10023 return qe_invalid;
10024 }
10025
10026
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10027 {
10028 return qe_invalid;
10029 }
10030
10031
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10032 {
10033 return qe_invalid;
10034 }
10035
10036 740 floatspr[i][spr_tile]=(int32_t)tile;
10037 740 floatspr[i][spr_flip]=(int32_t)flip;
10038 740 floatspr[i][spr_extend]=(int32_t)extend;
10039 740 }
10040
10041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(v_herosprites>1)
10042 {
10043
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
10044 {
10045
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10046 {
10047 return qe_invalid;
10048 }
10049
10050
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10051 {
10052 return qe_invalid;
10053 }
10054
10055
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10056 {
10057 return qe_invalid;
10058 }
10059
10060 740 swimspr[i][spr_tile]=(int32_t)tile;
10061 740 swimspr[i][spr_flip]=(int32_t)flip;
10062 740 swimspr[i][spr_extend]=(int32_t)extend;
10063 740 }
10064 185 }
10065
10066
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
10067 {
10068
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10069 {
10070 return qe_invalid;
10071 }
10072
10073
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10074 {
10075 return qe_invalid;
10076 }
10077
10078
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10079 {
10080 return qe_invalid;
10081 }
10082
10083 740 divespr[i][spr_tile]=(int32_t)tile;
10084 740 divespr[i][spr_flip]=(int32_t)flip;
10085 740 divespr[i][spr_extend]=(int32_t)extend;
10086 740 }
10087
10088
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
10089 {
10090
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10091 {
10092 return qe_invalid;
10093 }
10094
10095
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10096 {
10097 return qe_invalid;
10098 }
10099
10100
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10101 {
10102 return qe_invalid;
10103 }
10104
10105 740 poundspr[i][spr_tile]=(int32_t)tile;
10106 740 poundspr[i][spr_flip]=(int32_t)flip;
10107 740 poundspr[i][spr_extend]=(int32_t)extend;
10108 740 }
10109
10110
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&tile,f))
10111 {
10112 return qe_invalid;
10113 }
10114
10115 185 flip=0;
10116
10117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(v_herosprites>0)
10118 {
10119
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&flip,f))
10120 {
10121 return qe_invalid;
10122 }
10123 185 }
10124
10125
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&extend,f))
10126 {
10127 return qe_invalid;
10128 }
10129
10130 185 castingspr[spr_tile]=(int32_t)tile;
10131 185 castingspr[spr_flip]=(int32_t)flip;
10132 185 castingspr[spr_extend]=(int32_t)extend;
10133
10134
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(v_herosprites>0)
10135 {
10136 185 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10137
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 185 times.
555 for(int32_t i=0; i<2; i++)
10138 {
10139
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 370 times.
1110 for(int32_t j=0; j<num_holdsprs; j++)
10140 {
10141
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10142 {
10143 return qe_invalid;
10144 }
10145
10146
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10147 {
10148 return qe_invalid;
10149 }
10150
10151
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10152 {
10153 return qe_invalid;
10154 }
10155
10156 740 holdspr[i][j][spr_tile]=(int32_t)tile;
10157 740 holdspr[i][j][spr_flip]=(int32_t)flip;
10158 740 holdspr[i][j][spr_extend]=(int32_t)extend;
10159 740 }
10160 370 }
10161 185 }
10162 else
10163 {
10164 for(int32_t i=0; i<2; i++)
10165 {
10166 if(!p_igetw(&tile,f))
10167 {
10168 return qe_invalid;
10169 }
10170
10171 if(!p_igetw(&tile2,f))
10172 {
10173 return qe_invalid;
10174 }
10175
10176 if(!p_getc(&extend,f))
10177 {
10178 return qe_invalid;
10179 }
10180
10181 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10182 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10183 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10184 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10185 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10186 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10187 }
10188 }
10189
10190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(v_herosprites>2)
10191 {
10192
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
10193 {
10194
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10195 {
10196 return qe_invalid;
10197 }
10198
10199
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&extend,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209 740 jumpspr[i][spr_tile]=(int32_t)tile;
10210 740 jumpspr[i][spr_flip]=(int32_t)flip;
10211 740 jumpspr[i][spr_extend]=(int32_t)extend;
10212 740 }
10213 185 }
10214
10215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(v_herosprites>3)
10216 {
10217
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i=0; i<4; i++)
10218 {
10219
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_igetw(&tile,f))
10220 {
10221 return qe_invalid;
10222 }
10223
10224
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(!p_getc(&flip,f))
10225 {
10226 return qe_invalid;
10227 }
10228
10229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(!p_getc(&extend,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234 740 chargespr[i][spr_tile]=(int32_t)tile;
10235 740 chargespr[i][spr_flip]=(int32_t)flip;
10236 740 chargespr[i][spr_extend]=(int32_t)extend;
10237 740 }
10238 185 }
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(v_herosprites>4)
10241 {
10242
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&dummy_byte,f))
10243 {
10244 return qe_invalid;
10245 }
10246
10247 185 zinit.hero_swim_speed=(byte)dummy_byte;
10248 185 }
10249
10250 185 memset(frozenspr, 0, sizeof(frozenspr));
10251 185 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10252 185 memset(onfirespr, 0, sizeof(onfirespr));
10253 185 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10254 185 memset(diggingspr, 0, sizeof(diggingspr));
10255 185 memset(usingrodspr, 0, sizeof(usingrodspr));
10256 185 memset(usingcanespr, 0, sizeof(usingcanespr));
10257 185 memset(pushingspr, 0, sizeof(pushingspr));
10258 185 memset(liftingspr, 0, sizeof(liftingspr));
10259 185 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10260 185 memset(stunnedspr, 0, sizeof(stunnedspr));
10261 185 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10262 185 memset(fallingspr, 0, sizeof(fallingspr));
10263 185 memset(shockedspr, 0, sizeof(shockedspr));
10264 185 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10265 185 memset(pullswordspr, 0, sizeof(pullswordspr));
10266 185 memset(readingspr, 0, sizeof(readingspr));
10267 185 memset(slash180spr, 0, sizeof(slash180spr));
10268 185 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10269 185 memset(dashspr, 0, sizeof(dashspr));
10270 185 memset(bonkspr, 0, sizeof(bonkspr));
10271 185 memset(medallionsprs, 0, sizeof(medallionsprs));
10272 185 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10273 185 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10274
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t q = 0; q < 4; ++q)
10275 {
10276
2/2
✓ Branch 0 taken 2220 times.
✓ Branch 1 taken 740 times.
2960 for(int32_t p = 0; p < 3; ++p)
10277 {
10278 2220 drowningspr[q][p] = divespr[q][p];
10279 2220 drowning_lavaspr[q][p] = divespr[q][p];
10280 2220 }
10281 740 }
10282 185 memset(sideswimspr, 0, sizeof(sideswimspr));
10283 185 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10284 185 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10285 185 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10286 185 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10287 185 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10288 185 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10289 185 }
10290
10291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 if(FFCore.quest_format[vInitData] < 34)
10292 {
10293 290 bool fastswim = zinit.hero_swim_speed > 60;
10294 // '2/3' or '1/2'
10295 290 zinit.hero_swim_mult = fastswim ? 2 : 1;
10296 290 zinit.hero_swim_div = fastswim ? 3 : 2;
10297 290 }
10298 290 return 0;
10299 290 }
10300
10301 71230 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10302 {
10303 71230 arr[spr_tile] = tile;
10304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71230 times.
71230 arr[spr_flip] = (flip > 3 ? 0 : flip);
10305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71230 times.
71230 arr[spr_extend] = (ext > 2 ? 0 : ext);
10306 71230 }
10307 //Used to read the player sprites as int32_t, not word.
10308 419 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10309 {
10310 //these are here to bypass compiler warnings about unused arguments
10311 419 cv_herosprites=cv_herosprites;
10312
10313 419 zinit.hero_swim_speed=67; //default
10314 419 setupherotiles(zinit.heroAnimationStyle);
10315 419 setupherodefenses();
10316 419 setupherooffsets();
10317
10318 int32_t tile, tile2;
10319 byte flip, extend, dummy_byte;
10320
10321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(v_herosprites>=0)
10322 {
10323
10324
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10325 {
10326
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10327 {
10328 return qe_invalid;
10329 }
10330
10331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10332 {
10333 return qe_invalid;
10334 }
10335
10336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10337 {
10338 return qe_invalid;
10339 }
10340
10341 1676 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10342 1676 }
10343
10344
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10345 {
10346
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10347 {
10348 return qe_invalid;
10349 }
10350
10351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10352 {
10353 return qe_invalid;
10354 }
10355
10356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10357 {
10358 return qe_invalid;
10359 }
10360
10361 1676 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10362 1676 }
10363
10364
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10365 {
10366
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10367 {
10368 return qe_invalid;
10369 }
10370
10371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10372 {
10373 return qe_invalid;
10374 }
10375
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10377 {
10378 return qe_invalid;
10379 }
10380
10381 1676 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10382 1676 }
10383
10384
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10385 {
10386
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10397 {
10398 return qe_invalid;
10399 }
10400
10401 1676 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10402 1676 }
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(v_herosprites>1)
10405 {
10406
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10407 {
10408
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10409 {
10410 return qe_invalid;
10411 }
10412
10413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10414 {
10415 return qe_invalid;
10416 }
10417
10418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10419 {
10420 return qe_invalid;
10421 }
10422
10423 1676 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10424 1676 }
10425 419 }
10426
10427
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10428 {
10429
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10430 {
10431 return qe_invalid;
10432 }
10433
10434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10435 {
10436 return qe_invalid;
10437 }
10438
10439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10440 {
10441 return qe_invalid;
10442 }
10443
10444 1676 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10445 1676 }
10446
10447
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10448 {
10449
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10450 {
10451 return qe_invalid;
10452 }
10453
10454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10455 {
10456 return qe_invalid;
10457 }
10458
10459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10460 {
10461 return qe_invalid;
10462 }
10463
10464 1676 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10465 1676 }
10466
10467
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tile,f))
10468 {
10469 return qe_invalid;
10470 }
10471
10472 419 flip=0;
10473
10474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(v_herosprites>0)
10475 {
10476
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&flip,f))
10477 {
10478 return qe_invalid;
10479 }
10480 419 }
10481
10482
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&extend,f))
10483 {
10484 return qe_invalid;
10485 }
10486
10487 419 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10488
10489
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(v_herosprites>0)
10490 {
10491 419 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10492
2/2
✓ Branch 0 taken 838 times.
✓ Branch 1 taken 419 times.
1257 for(int32_t i=0; i<2; i++)
10493 {
10494
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 838 times.
3352 for(int32_t j=0; j<num_holdsprs; j++)
10495 {
10496
1/2
✓ Branch 0 taken 2514 times.
✗ Branch 1 not taken.
2514 if(!p_igetl(&tile,f))
10497 {
10498 return qe_invalid;
10499 }
10500
10501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2514 times.
2514 if(!p_getc(&flip,f))
10502 {
10503 return qe_invalid;
10504 }
10505
10506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2514 times.
2514 if(!p_getc(&extend,f))
10507 {
10508 return qe_invalid;
10509 }
10510
10511 2514 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10512 2514 }
10513 838 }
10514 419 }
10515 else
10516 {
10517 for(int32_t i=0; i<2; i++)
10518 {
10519 if(!p_igetl(&tile,f))
10520 {
10521 return qe_invalid;
10522 }
10523
10524 if(!p_igetl(&tile2,f))
10525 {
10526 return qe_invalid;
10527 }
10528
10529 if(!p_getc(&extend,f))
10530 {
10531 return qe_invalid;
10532 }
10533
10534 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10535 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10536 }
10537 }
10538
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(v_herosprites>2)
10540 {
10541
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10542 {
10543
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10544 {
10545 return qe_invalid;
10546 }
10547
10548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10549 {
10550 return qe_invalid;
10551 }
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558 1676 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10559 1676 }
10560 419 }
10561
10562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(v_herosprites>3)
10563 {
10564
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t i=0; i<4; i++)
10565 {
10566
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10567 {
10568 return qe_invalid;
10569 }
10570
10571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10572 {
10573 return qe_invalid;
10574 }
10575
10576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10577 {
10578 return qe_invalid;
10579 }
10580
10581 1676 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10582 1676 }
10583 419 }
10584
10585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(v_herosprites>4)
10586 {
10587
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&dummy_byte,f))
10588 {
10589 return qe_invalid;
10590 }
10591
10592 419 zinit.hero_swim_speed=(byte)dummy_byte;
10593 419 }
10594
10595
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(v_herosprites>6)
10596 {
10597
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10598 {
10599
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10600 return qe_invalid;
10601
10602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10603 return qe_invalid;
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10606 return qe_invalid;
10607
10608 1676 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10609 1676 }
10610
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10611 {
10612
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10613 return qe_invalid;
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10616 return qe_invalid;
10617
10618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10619 return qe_invalid;
10620
10621 1676 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10622 1676 }
10623
10624
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10625 {
10626
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10627 return qe_invalid;
10628
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10630 return qe_invalid;
10631
10632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10633 return qe_invalid;
10634
10635 1676 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10636 1676 }
10637
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10638 {
10639
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10640 return qe_invalid;
10641
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10643 return qe_invalid;
10644
10645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10646 return qe_invalid;
10647
10648 1676 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10649 1676 }
10650
10651
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10652 {
10653
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10654 return qe_invalid;
10655
10656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10657 return qe_invalid;
10658
10659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10660 return qe_invalid;
10661
10662 1676 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10663 1676 }
10664
10665
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10666 {
10667
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10668 return qe_invalid;
10669
10670
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10674 return qe_invalid;
10675
10676 1676 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10677 1676 }
10678
10679
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10682 return qe_invalid;
10683
10684
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10685 return qe_invalid;
10686
10687
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10688 return qe_invalid;
10689
10690 1676 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10691 1676 }
10692
10693
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10694 {
10695
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10696 return qe_invalid;
10697
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10699 return qe_invalid;
10700
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10702 return qe_invalid;
10703
10704 1676 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10705 1676 }
10706
10707
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10708 {
10709
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10710 return qe_invalid;
10711
10712
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10713 return qe_invalid;
10714
10715
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10716 return qe_invalid;
10717
10718 1676 byte frames = 0;
10719
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1656 times.
1676 if(v_herosprites > 15)
10720 {
10721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(!p_getc(&frames,f))
10722 return qe_invalid;
10723 1656 }
10724
10725 1676 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10726 1676 liftingspr[q][spr_frames] = frames;
10727 1676 }
10728
10729
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10730 {
10731
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10732 return qe_invalid;
10733
10734
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10735 return qe_invalid;
10736
10737
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10738 return qe_invalid;
10739
10740 1676 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10741 1676 }
10742
10743
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10744 {
10745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_igetl(&tile,f))
10746 return qe_invalid;
10747
10748
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10749 return qe_invalid;
10750
10751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10752 return qe_invalid;
10753
10754 1676 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10755 1676 }
10756
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10757 {
10758
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10759 return qe_invalid;
10760
10761
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10762 return qe_invalid;
10763
10764
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10765 return qe_invalid;
10766
10767 1676 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10768 1676 }
10769
10770
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10771 {
10772
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10773 return qe_invalid;
10774
10775
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10776 return qe_invalid;
10777
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10779 return qe_invalid;
10780
10781 1676 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10782 1676 }
10783
10784
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10785 {
10786
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10787 return qe_invalid;
10788
10789
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10790 return qe_invalid;
10791
10792
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10793 return qe_invalid;
10794
10795 1676 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10796 1676 }
10797
10798
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10799 {
10800
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10801 return qe_invalid;
10802
10803
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10804 return qe_invalid;
10805
10806
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10807 return qe_invalid;
10808
10809 1676 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10810 1676 }
10811
10812
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10813 {
10814
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10815 return qe_invalid;
10816
10817
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10818 return qe_invalid;
10819
10820
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10821 return qe_invalid;
10822
10823 1676 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10824 1676 }
10825
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10826 {
10827
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10831 return qe_invalid;
10832
10833
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10834 return qe_invalid;
10835
10836 1676 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10837 1676 }
10838
10839
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10842 return qe_invalid;
10843
10844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10845 return qe_invalid;
10846
10847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10848 return qe_invalid;
10849
10850 1676 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 1676 }
10852
10853
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10854 {
10855
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10856 return qe_invalid;
10857
10858
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10862 return qe_invalid;
10863
10864 1676 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10865 1676 }
10866
10867
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10868 {
10869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_igetl(&tile,f))
10870 return qe_invalid;
10871
10872
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10873 return qe_invalid;
10874
10875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10876 return qe_invalid;
10877
10878 1676 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10879 1676 }
10880
10881
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10882 {
10883
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10884 return qe_invalid;
10885
10886
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10887 return qe_invalid;
10888
10889
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10890 return qe_invalid;
10891
10892 1676 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10893 1676 }
10894
10895
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10896 {
10897
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10898 return qe_invalid;
10899
10900
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10901 return qe_invalid;
10902
10903
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10904 return qe_invalid;
10905
10906 1676 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10907 1676 }
10908
10909
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10910 {
10911
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&flip,f))
10915 return qe_invalid;
10916
10917
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_getc(&extend,f))
10918 return qe_invalid;
10919
10920 1676 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10921 1676 }
10922
10923
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 419 times.
1676 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10924 {
10925
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 if(!p_igetl(&tile,f))
10926 return qe_invalid;
10927
10928
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 if(!p_getc(&flip,f))
10929 return qe_invalid;
10930
10931
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 if(!p_getc(&extend,f))
10932 return qe_invalid;
10933
10934 1257 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10935 1257 }
10936 419 }
10937 else
10938 {
10939 memset(frozenspr, 0, sizeof(frozenspr));
10940 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10941 memset(onfirespr, 0, sizeof(onfirespr));
10942 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10943 memset(diggingspr, 0, sizeof(diggingspr));
10944 memset(usingrodspr, 0, sizeof(usingrodspr));
10945 memset(usingcanespr, 0, sizeof(usingcanespr));
10946 memset(pushingspr, 0, sizeof(pushingspr));
10947 memset(liftingspr, 0, sizeof(liftingspr));
10948 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10949 memset(stunnedspr, 0, sizeof(stunnedspr));
10950 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10951 memset(fallingspr, 0, sizeof(fallingspr));
10952 memset(shockedspr, 0, sizeof(shockedspr));
10953 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10954 memset(pullswordspr, 0, sizeof(pullswordspr));
10955 memset(readingspr, 0, sizeof(readingspr));
10956 memset(slash180spr, 0, sizeof(slash180spr));
10957 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10958 memset(dashspr, 0, sizeof(dashspr));
10959 memset(bonkspr, 0, sizeof(bonkspr));
10960 memset(medallionsprs, 0, sizeof(medallionsprs));
10961 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10962 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10963 for(int32_t q = 0; q < 4; ++q)
10964 {
10965 for(int32_t p = 0; p < 3; ++p)
10966 {
10967 drowningspr[q][p] = divespr[q][p];
10968 drowning_lavaspr[q][p] = divespr[q][p];
10969 }
10970 }
10971 }
10972
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 8)
10973 {
10974
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10975 {
10976
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10977 return qe_invalid;
10978
10979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
10980 return qe_invalid;
10981
10982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
10983 return qe_invalid;
10984
10985 1676 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10986 1676 }
10987 419 }
10988 else
10989 {
10990 memset(sideswimspr, 0, sizeof(sideswimspr));
10991 }
10992
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 9)
10993 {
10994
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
10995 {
10996
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
10997 return qe_invalid;
10998
10999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
11000 return qe_invalid;
11001
11002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
11003 return qe_invalid;
11004
11005 1676 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11006 1676 }
11007
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
11008 {
11009
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
11010 return qe_invalid;
11011
11012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
11013 return qe_invalid;
11014
11015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
11016 return qe_invalid;
11017
11018 1676 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11019 1676 }
11020
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
11021 {
11022
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
11023 return qe_invalid;
11024
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
11029 return qe_invalid;
11030
11031 1676 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11032 1676 }
11033
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
11034 {
11035
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
11042 return qe_invalid;
11043
11044 1676 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11045 1676 }
11046 419 }
11047 else
11048 {
11049 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11050 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11051 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11052 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11053 }
11054
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 10)
11055 {
11056
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
11057 {
11058 int32_t hmr;
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_igetl(&hmr,f))
11060 return qe_invalid;
11061
11062 1676 hammeroffsets[q] = hmr;
11063 1676 }
11064 419 }
11065 else
11066 {
11067 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11068 }
11069
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 11)
11070 {
11071
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 419 times.
1676 for(int32_t q = 0; q < 3; ++q)
11072 {
11073
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 if(!p_igetl(&tile,f))
11074 return qe_invalid;
11075
11076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if(!p_getc(&flip,f))
11077 return qe_invalid;
11078
11079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if(!p_getc(&extend,f))
11080 return qe_invalid;
11081
11082 1257 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11083 1257 }
11084 419 }
11085 else
11086 {
11087 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11088 }
11089
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 12)
11090 {
11091
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tile,f))
11092 return qe_invalid;
11093
11094
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&flip,f))
11095 return qe_invalid;
11096
11097
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_getc(&extend,f))
11098 return qe_invalid;
11099 419 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11100
11101 419 }
11102 else
11103 {
11104 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11105 }
11106
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 13)
11107 {
11108
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
11109 {
11110
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
11111 return qe_invalid;
11112
11113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
11114 return qe_invalid;
11115
11116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
11117 return qe_invalid;
11118
11119 1676 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11120 1676 }
11121 419 }
11122 else
11123 {
11124 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11125 }
11126
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 14)
11127 {
11128
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 419 times.
2095 for(int32_t q = 0; q < 4; ++q)
11129 {
11130
1/2
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
1676 if(!p_igetl(&tile,f))
11131 return qe_invalid;
11132
11133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&flip,f))
11134 return qe_invalid;
11135
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1676 times.
1676 if(!p_getc(&extend,f))
11137 return qe_invalid;
11138
11139 1676 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11140 1676 }
11141 419 }
11142 else
11143 {
11144 memset(revslashspr, 0, sizeof(revslashspr));
11145 }
11146
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if (v_herosprites > 7)
11147 {
11148 419 int32_t num_defense = wMax;
11149 419 byte def = 0;
11150
11151 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11152 /*if(v_herosprites > [x])
11153 * {
11154 * num_defense = 146 //value of wMax on version 8
11155 * }
11156 */
11157
11158
2/2
✓ Branch 0 taken 61174 times.
✓ Branch 1 taken 419 times.
61593 for (int32_t q = 0; q < num_defense; q++)
11159 {
11160
1/2
✓ Branch 0 taken 61174 times.
✗ Branch 1 not taken.
61174 if (!p_getc(&def, f))
11161 return qe_invalid;
11162
11163 61174 hero_defence[q] = def;
11164 61174 }
11165 419 }
11166 else
11167 {
11168 int32_t num_defense = wMax;
11169 for (int32_t q = 0; q < num_defense; q++)
11170 {
11171 hero_defence[q] = 0;
11172 }
11173 }
11174 419 }
11175
11176
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 11 times.
419 if(FFCore.quest_format[vInitData] < 34)
11177 {
11178 11 bool fastswim = zinit.hero_swim_speed > 60;
11179 // '2/3' or '1/2'
11180 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11181 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11182 11 }
11183 419 return 0;
11184 419 }
11185
11186
11187 604 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11188 {
11189 //these are here to bypass compiler warnings about unused arguments
11190 604 Header=Header;
11191
11192 dword dummy;
11193 604 word s_version=0, s_cversion=0;
11194
11195 //section version info
11196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_igetw(&s_version,f))
11197 {
11198 return qe_invalid;
11199 }
11200
11201 604 FFCore.quest_format[vHeroSprites] = s_version;
11202
11203 //al_trace("Player sprites version %d\n", s_version);
11204
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
11205 {
11206 return qe_invalid;
11207 }
11208
11209 //section size
11210
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&dummy,f))
11211 {
11212 return qe_invalid;
11213 }
11214
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if ( s_version >= 6 )
11215 {
11216 //al_trace("Reading Player Sprites v6\n");
11217 419 return readherosprites3(f, s_version, dummy);
11218 }
11219 185 else return readherosprites2(f, s_version, dummy);
11220 604 }
11221
11222 203 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11223 {
11224 203 subscreens_active.clear();
11225 203 subscreens_passive.clear();
11226 203 subscreens_overlay.clear();
11227
2/2
✓ Branch 0 taken 25984 times.
✓ Branch 1 taken 203 times.
26187 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11228 {
11229 subscreen_group g;
11230 25984 memset(&g,0,sizeof(subscreen_group));
11231 25984 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25984 times.
25984 if(ret!=0)
11233 return ret;
11234
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 24958 times.
25984 if(g.objects[0].type == ssoNULL) continue;
11235
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 592 times.
1026 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11236 1026 ZCSubscreen& sub = vec.emplace_back();
11237 1026 sub.load_old(g);
11238 1026 }
11239
11240 203 return 0;
11241 203 }
11242
11243 25984 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11244 {
11245 25984 int32_t numsub=0;
11246 25984 byte temp_ss=0;
11247 subscreen_object temp_sub_stack;
11248 25984 subscreen_object *temp_sub = &temp_sub_stack;
11249
11250 char tempname[64];
11251
11252 // FWIW I never saw anything bigger than 20.
11253 #define MAX_DP1_LEN 1024
11254 char tempdp1[MAX_DP1_LEN];
11255
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25984 times.
25984 if(!pfread(tempname,64,f))
11257 {
11258 return qe_invalid;
11259 }
11260
11261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25984 times.
25984 if(s_version > 1)
11262 {
11263
1/2
✓ Branch 0 taken 25984 times.
✗ Branch 1 not taken.
25984 if(!p_getc(&temp_ss,f))
11264 {
11265 return qe_invalid;
11266 }
11267 25984 }
11268
11269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25984 times.
25984 if(s_version < 4)
11270 {
11271 uint8_t tmp=0;
11272
11273 if(!p_getc(&tmp,f))
11274 {
11275 return qe_invalid;
11276 }
11277
11278 numsub = (int32_t)tmp;
11279 }
11280 else
11281 {
11282 word tmp;
11283
11284
1/2
✓ Branch 0 taken 25984 times.
✗ Branch 1 not taken.
25984 if(!p_igetw(&tmp, f))
11285 {
11286 return qe_invalid;
11287 }
11288
11289 25984 numsub = (int32_t)tmp;
11290 }
11291
11292 int32_t j;
11293
11294
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 65994 times.
✓ Branch 2 taken 40010 times.
✓ Branch 3 taken 25984 times.
65994 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11295 {
11296 40010 memset(temp_sub,0,sizeof(subscreen_object));
11297
11298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40010 times.
40010 switch(g->objects[j].type)
11299 {
11300 case ssoTEXT:
11301 case ssoTEXTBOX:
11302 case ssoCURRENTITEMTEXT:
11303 case ssoCURRENTITEMCLASSTEXT:
11304 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11305
11306 //fall through
11307 default:
11308 40010 memset(&g->objects[j],0,sizeof(subscreen_object));
11309 40010 break;
11310 }
11311
11312
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->type),f))
11313 return qe_invalid;
11314
11315
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->pos),f))
11316 return qe_invalid;
11317
11318
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(s_version < 5)
11319 {
11320 switch(temp_sub->pos)
11321 {
11322 case 0:
11323 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11324 break;
11325
11326 case 1:
11327 temp_sub->pos = sspUP;
11328 break;
11329
11330 case 2:
11331 temp_sub->pos = sspDOWN;
11332 break;
11333
11334 default:
11335 temp_sub->pos = 0;
11336 }
11337 }
11338
11339
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->x),f))
11340 return qe_invalid;
11341
11342
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->y),f))
11343 return qe_invalid;
11344
11345
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->w),f))
11346 return qe_invalid;
11347
11348
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->h),f))
11349 return qe_invalid;
11350
11351
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->colortype1),f))
11352 return qe_invalid;
11353
11354
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->color1),f))
11355 return qe_invalid;
11356
11357
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->colortype2),f))
11358 return qe_invalid;
11359
11360
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->color2),f))
11361 return qe_invalid;
11362
11363
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->colortype3),f))
11364 return qe_invalid;
11365
11366
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->color3),f))
11367 return qe_invalid;
11368
11369
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d1),f))
11370 return qe_invalid;
11371
11372
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d2),f))
11373 return qe_invalid;
11374
11375
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d3),f))
11376 return qe_invalid;
11377
11378
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d4),f))
11379 return qe_invalid;
11380
11381
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d5),f))
11382 return qe_invalid;
11383
11384
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d6),f))
11385 return qe_invalid;
11386
11387
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d7),f))
11388 return qe_invalid;
11389
11390
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d8),f))
11391 return qe_invalid;
11392
11393
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d9),f))
11394 return qe_invalid;
11395
11396
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetd(&(temp_sub->d10),f))
11397 return qe_invalid;
11398
11399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40010 times.
40010 if(s_version < 2)
11400 {
11401 if(!p_igetl(&(temp_sub->speed),f))
11402 return qe_invalid;
11403
11404 if(!p_igetl(&(temp_sub->delay),f))
11405 return qe_invalid;
11406
11407 if(!p_igetl(&(temp_sub->frame),f))
11408 return qe_invalid;
11409 }
11410 else
11411 {
11412
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->speed),f))
11413 return qe_invalid;
11414
11415
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_getc(&(temp_sub->delay),f))
11416 return qe_invalid;
11417
11418
1/2
✓ Branch 0 taken 40010 times.
✗ Branch 1 not taken.
40010 if(!p_igetw(&(temp_sub->frame),f))
11419 return qe_invalid;
11420 }
11421
11422 40010 int32_t temp_size=0;
11423
11424 // bool deletets = false;
11425
4/4
✓ Branch 0 taken 17360 times.
✓ Branch 1 taken 3154 times.
✓ Branch 2 taken 19296 times.
✓ Branch 3 taken 200 times.
40010 switch(temp_sub->type)
11426 {
11427 case ssoTEXT:
11428 case ssoTEXTBOX:
11429 case ssoCURRENTITEMTEXT:
11430 case ssoCURRENTITEMCLASSTEXT:
11431 {
11432 word temptempsize;
11433
11434
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 if(!p_igetw(&temptempsize,f))
11435 {
11436 return qe_invalid;
11437 }
11438
11439 //temptempsize = temp1 + (temp2 << 8);
11440 3154 temp_size = (int32_t)temptempsize;
11441 3154 uint32_t char_length = temp_size+2;
11442
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 if (char_length > MAX_DP1_LEN)
11443 {
11444 return qe_invalid;
11445 }
11446 3154 tempdp1[char_length - 1] = '\0';
11447
11448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3154 times.
3154 if(temp_size)
11449
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 if(!pfread(tempdp1,temp_size+1,f))
11450 return qe_invalid;
11451 3154 break;
11452 }
11453
11454 case ssoLIFEMETER:
11455
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11456 temp_sub->d3 = 1;
11457
11458
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&(temp_sub->dp1),f))
11459 return qe_invalid;
11460
11461 200 break;
11462
11463
11464 case ssoCURRENTITEM:
11465
11466
1/2
✓ Branch 0 taken 17360 times.
✗ Branch 1 not taken.
17360 if(s_version < 6)
11467 {
11468 switch(temp_sub->d1)
11469 {
11470 case ssiBOMB:
11471 temp_sub->d1 = itype_bomb;
11472 break;
11473
11474 case ssiSWORD:
11475 temp_sub->d1 = itype_sword;
11476 break;
11477
11478 case ssiSHIELD:
11479 temp_sub->d1 = itype_shield;
11480 break;
11481
11482 case ssiCANDLE:
11483 temp_sub->d1 = itype_candle;
11484 break;
11485
11486 case ssiLETTER:
11487 temp_sub->d1 = itype_letter;
11488 break;
11489
11490 case ssiPOTION:
11491 temp_sub->d1 = itype_potion;
11492 break;
11493
11494 case ssiLETTERPOTION:
11495 temp_sub->d1 = itype_letterpotion;
11496 break;
11497
11498 case ssiBOW:
11499 temp_sub->d1 = itype_bow;
11500 break;
11501
11502 case ssiARROW:
11503 temp_sub->d1 = itype_arrow;
11504 break;
11505
11506 case ssiBOWANDARROW:
11507 temp_sub->d1 = itype_bowandarrow;
11508 break;
11509
11510 case ssiBAIT:
11511 temp_sub->d1 = itype_bait;
11512 break;
11513
11514 case ssiRING:
11515 temp_sub->d1 = itype_ring;
11516 break;
11517
11518 case ssiBRACELET:
11519 temp_sub->d1 = itype_bracelet;
11520 break;
11521
11522 case ssiMAP:
11523 temp_sub->d1 = itype_map;
11524 break;
11525
11526 case ssiCOMPASS:
11527 temp_sub->d1 = itype_compass;
11528 break;
11529
11530 case ssiBOSSKEY:
11531 temp_sub->d1 = itype_bosskey;
11532 break;
11533
11534 case ssiMAGICKEY:
11535 temp_sub->d1 = itype_magickey;
11536 break;
11537
11538 case ssiBRANG:
11539 temp_sub->d1 = itype_brang;
11540 break;
11541
11542 case ssiWAND:
11543 temp_sub->d1 = itype_wand;
11544 break;
11545
11546 case ssiRAFT:
11547 temp_sub->d1 = itype_raft;
11548 break;
11549
11550 case ssiLADDER:
11551 temp_sub->d1 = itype_ladder;
11552 break;
11553
11554 case ssiWHISTLE:
11555 temp_sub->d1 = itype_whistle;
11556 break;
11557
11558 case ssiBOOK:
11559 temp_sub->d1 = itype_book;
11560 break;
11561
11562 case ssiWALLET:
11563 temp_sub->d1 = itype_wallet;
11564 break;
11565
11566 case ssiSBOMB:
11567 temp_sub->d1 = itype_sbomb;
11568 break;
11569
11570 case ssiHCPIECE:
11571 temp_sub->d1 = itype_heartpiece;
11572 break;
11573
11574 case ssiAMULET:
11575 temp_sub->d1 = itype_amulet;
11576 break;
11577
11578 case ssiFLIPPERS:
11579 temp_sub->d1 = itype_flippers;
11580 break;
11581
11582 case ssiHOOKSHOT:
11583 temp_sub->d1 = itype_hookshot;
11584 break;
11585
11586 case ssiLENS:
11587 temp_sub->d1 = itype_lens;
11588 break;
11589
11590 case ssiHAMMER:
11591 temp_sub->d1 = itype_hammer;
11592 break;
11593
11594 case ssiBOOTS:
11595 temp_sub->d1 = itype_boots;
11596 break;
11597
11598 case ssiDIVINEFIRE:
11599 temp_sub->d1 = itype_divinefire;
11600 break;
11601
11602 case ssiDIVINEESCAPE:
11603 temp_sub->d1 = itype_divineescape;
11604 break;
11605
11606 case ssiDIVINEPROTECTION:
11607 temp_sub->d1 = itype_divineprotection;
11608 break;
11609
11610 case ssiQUIVER:
11611 temp_sub->d1 = itype_quiver;
11612 break;
11613
11614 case ssiBOMBBAG:
11615 temp_sub->d1 = itype_bombbag;
11616 break;
11617
11618 case ssiCBYRNA:
11619 temp_sub->d1 = itype_cbyrna;
11620 break;
11621
11622 case ssiROCS:
11623 temp_sub->d1 = itype_rocs;
11624 break;
11625
11626 case ssiHOVERBOOTS:
11627 temp_sub->d1 = itype_hoverboots;
11628 break;
11629
11630 case ssiSPINSCROLL:
11631 temp_sub->d1 = itype_spinscroll;
11632 break;
11633
11634 case ssiCROSSSCROLL:
11635 temp_sub->d1 = itype_crossscroll;
11636 break;
11637
11638 case ssiQUAKESCROLL:
11639 temp_sub->d1 = itype_quakescroll;
11640 break;
11641
11642 case ssiWHISPRING:
11643 temp_sub->d1 = itype_whispring;
11644 break;
11645
11646 case ssiCHARGERING:
11647 temp_sub->d1 = itype_chargering;
11648 break;
11649
11650 case ssiPERILSCROLL:
11651 temp_sub->d1 = itype_perilscroll;
11652 break;
11653
11654 case ssiWEALTHMEDAL:
11655 temp_sub->d1 = itype_wealthmedal;
11656 break;
11657
11658 case ssiHEARTRING:
11659 temp_sub->d1 = itype_heartring;
11660 break;
11661
11662 case ssiMAGICRING:
11663 temp_sub->d1 = itype_magicring;
11664 break;
11665
11666 case ssiSPINSCROLL2:
11667 temp_sub->d1 = itype_spinscroll2;
11668 break;
11669
11670 case ssiQUAKESCROLL2:
11671 temp_sub->d1 = itype_quakescroll2;
11672 break;
11673
11674 case ssiAGONY:
11675 temp_sub->d1 = itype_agony;
11676 break;
11677
11678 case ssiSTOMPBOOTS:
11679 temp_sub->d1 = itype_stompboots;
11680 break;
11681
11682 case ssiWHIMSICALRING:
11683 temp_sub->d1 = itype_whimsicalring;
11684 break;
11685
11686 case ssiPERILRING:
11687 temp_sub->d1 = itype_perilring;
11688 break;
11689
11690 default:
11691 temp_sub->d1 += itype_custom1 - ssiMAX;
11692 }
11693 }
11694
11695 //fall-through
11696 default:
11697
1/2
✓ Branch 0 taken 36656 times.
✗ Branch 1 not taken.
36656 if(!p_getc(&(temp_sub->dp1),f))
11698 return qe_invalid;
11699
11700 36656 break;
11701 }
11702
11703
2/2
✓ Branch 0 taken 9237 times.
✓ Branch 1 taken 30773 times.
40010 if(s_version < 7)
11704 {
11705
3/3
✓ Branch 0 taken 24783 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 4624 times.
30773 switch(temp_sub->type)
11706 {
11707 case ssoMAGICGAUGE:
11708 {
11709
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1248 times.
1366 if(!temp_sub->d9)
11710 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11711 1366 break;
11712 }
11713 case ssoLIFEGAUGE:
11714 4624 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11715 4624 break;
11716 }
11717 30773 }
11718
11719
3/3
✓ Branch 0 taken 3154 times.
✓ Branch 1 taken 35458 times.
✓ Branch 2 taken 1398 times.
40010 switch(temp_sub->type)
11720 {
11721 case ssoTEXT:
11722 case ssoTEXTBOX:
11723 case ssoCURRENTITEMTEXT:
11724 case ssoCURRENTITEMCLASSTEXT:
11725
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3154 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11726
11727 3154 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11728 3154 g->objects[j].dp1 = new char[temp_size+2];
11729 3154 strcpy((char*)g->objects[j].dp1,tempdp1);
11730 3154 break;
11731
11732 case ssoCOUNTER:
11733
1/2
✓ Branch 0 taken 1398 times.
✗ Branch 1 not taken.
1398 if(s_version<3)
11734 {
11735 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11736 temp_sub->d8=0;
11737 }
11738
11739 default:
11740 36856 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11741 36856 break;
11742 }
11743
11744 40010 g->name[0] = '\0';
11745 40010 strncat(g->name, tempname, 64 - 1);
11746 40010 g->ss_type = temp_ss;
11747 40010 }
11748
11749
2/2
✓ Branch 0 taken 6611894 times.
✓ Branch 1 taken 25984 times.
6637878 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11750 {
11751 //clear all unused object in this subscreen -DD
11752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6611894 times.
6611894 switch(g->objects[j].type)
11753 {
11754 case ssoTEXT:
11755 case ssoTEXTBOX:
11756 case ssoCURRENTITEMTEXT:
11757 case ssoCURRENTITEMCLASSTEXT:
11758 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11759
11760 //fall through
11761 default:
11762 6611894 memset(&g->objects[j],0,sizeof(subscreen_object));
11763 6611894 break;
11764 }
11765 6611894 }
11766
11767 25984 return 0;
11768 25984 }
11769
11770 604 int32_t readsubscreens(PACKFILE *f)
11771 {
11772 word s_version, s_cversion;
11773 dword dummy;
11774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_igetw(&s_version,f))
11775 return qe_invalid;
11776 604 FFCore.quest_format[vSubscreen] = s_version;
11777
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
11778 return qe_invalid;
11779
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&dummy,f)) //section size
11780 return qe_invalid;
11781
11782
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 401 times.
604 if(s_version < 8)
11783 203 return read_old_subscreens(f,s_version);
11784
11785 401 subscreens_active.clear();
11786 401 subscreens_passive.clear();
11787 401 subscreens_overlay.clear();
11788
11789 byte sz;
11790
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 if(!p_getc(&sz,f))
11791 return qe_invalid;
11792
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 401 times.
1167 for(byte q = 0; q < sz; ++q)
11793 {
11794 766 ZCSubscreen& tmp = subscreens_active.emplace_back();
11795
1/2
✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
766 if (auto ret = tmp.read(f, s_version))
11796 return ret;
11797 766 }
11798
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 if(!p_getc(&sz,f))
11799 return qe_invalid;
11800
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 401 times.
1969 for(byte q = 0; q < sz; ++q)
11801 {
11802 1568 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11803
1/2
✓ Branch 0 taken 1568 times.
✗ Branch 1 not taken.
1568 if (auto ret = tmp.read(f, s_version))
11804 return ret;
11805 1568 }
11806
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 if(!p_getc(&sz,f))
11807 return qe_invalid;
11808
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 401 times.
947 for(byte q = 0; q < sz; ++q)
11809 {
11810 546 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if (auto ret = tmp.read(f, s_version))
11812 return ret;
11813 546 }
11814 401 return 0;
11815 604 }
11816
11817 void reset_subscreen(subscreen_group *tempss)
11818 {
11819 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11820 {
11821 switch(tempss->objects[i].type)
11822 {
11823 case ssoTEXT:
11824 case ssoTEXTBOX:
11825 case ssoCURRENTITEMTEXT:
11826 case ssoCURRENTITEMCLASSTEXT:
11827 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11828
11829 //fall through
11830 default:
11831 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11832 break;
11833 }
11834 }
11835 }
11836
11837 107 void reset_subscreens()
11838 {
11839 107 subscreens_active.clear();
11840 107 subscreens_passive.clear();
11841 107 subscreens_overlay.clear();
11842 107 }
11843
11844 107 int32_t setupsubscreens()
11845 {
11846 107 reset_subscreens();
11847 //return 0;
11848
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 214 times.
321 for(int q = 0; q < 2; ++q)
11849 {
11850 214 subscreens_active.emplace_back();
11851 214 subscreens_passive.emplace_back();
11852 214 }
11853 107 int32_t tempsubscreen=subscr_mode;
11854
11855
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(tempsubscreen>=ssdtMAX)
11856 tempsubscreen=0;
11857
11858
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
107 switch(tempsubscreen)
11859 {
11860 case ssdtOLD:
11861 case ssdtNEWSUBSCR:
11862 case ssdtREV2:
11863 case ssdtBSZELDA:
11864 case ssdtBSZELDAMODIFIED:
11865 case ssdtBSZELDAENHANCED:
11866 case ssdtBSZELDACOMPLETE:
11867 {
11868 107 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11869 107 subscreens_active[0].sub_type=sstACTIVE;
11870 107 subscreens_active[0].name = "Active Subscreen (Triforce)";
11871 107 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11872 107 subscreens_active[1].sub_type=sstACTIVE;
11873 107 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11874 107 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11875 107 subscreens_passive[0].sub_type=sstPASSIVE;
11876 107 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11877 107 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11878 107 subscreens_passive[1].sub_type=sstPASSIVE;
11879 107 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11880 107 break;
11881 }
11882
11883 case ssdtZ3:
11884 {
11885 subscreens_active[0].load_old(z3_active_a);
11886 subscreens_active[0].sub_type=sstACTIVE;
11887 subscreens_active[1].load_old(z3_active_ab);
11888 subscreens_active[1].sub_type=sstACTIVE;
11889 subscreens_passive[0].load_old(z3_passive_a);
11890 subscreens_passive[0].sub_type=sstPASSIVE;
11891 subscreens_passive[1].load_old(z3_passive_ab);
11892 subscreens_passive[1].sub_type=sstPASSIVE;
11893 break;
11894 }
11895 }
11896 107 subscr_mode = ssdtMAX;
11897 107 return 0;
11898 }
11899
11900 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11901
11902 extern script_data *ffscripts[NUMSCRIPTFFC];
11903 extern script_data *itemscripts[NUMSCRIPTITEM];
11904 extern script_data *guyscripts[NUMSCRIPTGUYS];
11905 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11906 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11907 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11908 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11909 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11910 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11911 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11912 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11913 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11914 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11915
11916 static std::vector<const script_data*> read_scripts;
11917
11918 1074 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11919 {
11920 int32_t dummy;
11921 1074 word s_version=0, s_cversion=0, zmeta_version=0;
11922 1074 byte numscripts=0;
11923 1074 numscripts=numscripts; //to avoid unused variables warnings
11924 int32_t ret;
11925 1074 read_scripts.clear();
11926 1074 zasm_scripts.clear();
11927
11928 //section version info
11929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1074 times.
1074 if(!p_igetw(&s_version,f))
11930 {
11931 return qe_invalid;
11932 }
11933
11934 1074 FFCore.quest_format[vFFScript] = s_version;
11935
11936
1/2
✓ Branch 0 taken 1074 times.
✗ Branch 1 not taken.
1074 if(!p_igetw(&s_cversion,f))
11937 {
11938 return qe_invalid;
11939 }
11940
11941
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 419 times.
1074 if(s_version >= 18)
11942 {
11943
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetw(&zmeta_version,f))
11944 {
11945 return qe_invalid;
11946 }
11947 419 }
11948
11949 //al_trace("Scripts version %d\n", s_version);
11950 //section size
11951
1/2
✓ Branch 0 taken 1074 times.
✗ Branch 1 not taken.
1074 if(!p_igetl(&dummy,f))
11952 {
11953 return qe_invalid;
11954 }
11955
11956
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 203 times.
1074 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
11957 1074 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
11958
11959 //finally... section data
11960
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 1072 times.
310322 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
11961 {
11962 309248 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
11963
11964
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if (ret)
11965 {
11966 return qe_invalid;
11967 }
11968 309248 }
11969
11970 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
11971 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
11972 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
11973 * there was a version bump a week before a change that broke stuff.
11974 */
11975
7/8
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 419 times.
✓ Branch 4 taken 419 times.
✓ Branch 5 taken 419 times.
✓ Branch 6 taken 419 times.
✓ Branch 7 taken 419 times.
1072 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
11976 {
11977 1491 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
11978 1491 }
11979
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if(s_version < 19)
11980 {
11981 185 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
11982 185 }
11983
11984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(s_version > 1)
11985 {
11986
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 604 times.
155228 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
11987 {
11988 154624 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
11989
11990
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if (ret)
11991 {
11992 return qe_invalid;
11993 }
11994 154624 }
11995
11996
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 604 times.
155228 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
11997 {
11998 154624 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
11999
12000
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if (ret)
12001 {
12002 return qe_invalid;
12003 }
12004 154624 }
12005
12006
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 script_data *fake = new script_data(ScriptType::None, 0);
12007
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 604 times.
155228 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12008 {
12009 154624 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12010
12011
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if (ret)
12012 {
12013 return qe_invalid;
12014 }
12015 154624 }
12016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 delete fake;
12017
12018
2/2
✓ Branch 0 taken 154624 times.
✓ Branch 1 taken 604 times.
155228 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12019 {
12020 154624 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12021
12022
1/2
✓ Branch 0 taken 154624 times.
✗ Branch 1 not taken.
154624 if (ret)
12023 {
12024 return qe_invalid;
12025 }
12026 154624 }
12027
12028
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if(s_version > 16)
12029 {
12030
2/2
✓ Branch 0 taken 3352 times.
✓ Branch 1 taken 419 times.
3771 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12031 {
12032 3352 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12033
12034
1/2
✓ Branch 0 taken 3352 times.
✗ Branch 1 not taken.
3352 if (ret)
12035 {
12036 return qe_invalid;
12037 }
12038 3352 }
12039 419 }
12040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 else if(s_version > 13)
12041 {
12042 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12043 {
12044 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12045
12046 if (ret)
12047 {
12048 return qe_invalid;
12049 }
12050 }
12051
12052 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12053 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12054
12055 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12056 }
12057
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 else if(s_version > 4)
12058 {
12059
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 185 times.
925 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12060 {
12061 740 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12062
12063
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (ret)
12064 {
12065 return qe_invalid;
12066 }
12067 740 }
12068
12069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12070
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12071
12072
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12073
12074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12075
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12076
12077
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12078
12079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12080
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 delete globalscripts[GLOBAL_SCRIPT_F6];
12081
12082
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12083
12084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12085
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12086
12087
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12088 185 }
12089 else
12090 {
12091 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12092 {
12093 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12094
12095 if (ret)
12096 {
12097 return qe_invalid;
12098 }
12099 }
12100
12101 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12102 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12103
12104 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12105
12106 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12107 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12108
12109 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12110
12111 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12113
12114 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12115
12116 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12117 delete globalscripts[GLOBAL_SCRIPT_F6];
12118
12119 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12120
12121 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12122 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12123
12124 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12125 }
12126
12127
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if(s_version > 10) //expanded the number of Player scripts to 5.
12128 {
12129
2/2
✓ Branch 0 taken 2095 times.
✓ Branch 1 taken 419 times.
2514 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12130 {
12131 2095 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12132
12133
1/2
✓ Branch 0 taken 2095 times.
✗ Branch 1 not taken.
2095 if (ret)
12134 {
12135 return qe_invalid;
12136 }
12137 2095 }
12138 419 }
12139 else
12140 {
12141
2/2
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 185 times.
740 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12142 {
12143 555 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12144
12145
1/2
✓ Branch 0 taken 555 times.
✗ Branch 1 not taken.
555 if (ret)
12146 {
12147 return qe_invalid;
12148 }
12149 555 }
12150
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(playerscripts[3] != NULL)
12151
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 delete playerscripts[3];
12152
12153
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 playerscripts[3] = new script_data(ScriptType::Player, 3);
12154
12155
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(playerscripts[4] != NULL)
12156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 delete playerscripts[4];
12157
12158
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 playerscripts[4] = new script_data(ScriptType::Player, 4);
12159 }
12160
3/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
604 if(s_version > 8 && s_version < 10)
12161 {
12162
12163 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12164 {
12165 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12166
12167 if (ret)
12168 {
12169 return qe_invalid;
12170 }
12171 }
12172 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12173 {
12174 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12175
12176 if (ret)
12177 {
12178 return qe_invalid;
12179 }
12180 }
12181
12182 }
12183
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version >= 10)
12184 {
12185
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12186 {
12187 107264 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12188
12189
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if (ret)
12190 {
12191 return qe_invalid;
12192 }
12193 107264 }
12194
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12195 {
12196 107264 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12197
12198
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if (ret)
12199 {
12200 return qe_invalid;
12201 }
12202 107264 }
12203
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12204 {
12205 107264 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12206
12207
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if (ret)
12208 {
12209 return qe_invalid;
12210 }
12211 107264 }
12212
12213 419 }
12214
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version >=12)
12215 {
12216
2/2
✓ Branch 0 taken 107264 times.
✓ Branch 1 taken 419 times.
107683 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12217 {
12218 107264 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12219
12220
1/2
✓ Branch 0 taken 107264 times.
✗ Branch 1 not taken.
107264 if (ret)
12221 {
12222 return qe_invalid;
12223 }
12224 107264 }
12225 419 }
12226
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version >=15)
12227 {
12228
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 419 times.
214947 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12229 {
12230 214528 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12231
12232
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if (ret)
12233 {
12234 return qe_invalid;
12235 }
12236 214528 }
12237 419 }
12238
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version >19)
12239 {
12240 419 word numgenscripts = NUMSCRIPTSGENERIC;
12241
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetw(&numgenscripts,f))
12242 {
12243 return qe_invalid;
12244 }
12245
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 419 times.
214947 for(int32_t i = 0; i < numgenscripts; i++)
12246 {
12247 214528 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12248
12249
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if (ret)
12250 {
12251 return qe_invalid;
12252 }
12253 214528 }
12254 419 }
12255
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 401 times.
604 if(s_version >21)
12256 {
12257 401 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12258
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 if(!p_igetw(&numsubscripts,f))
12259 {
12260 return qe_invalid;
12261 }
12262
2/2
✓ Branch 0 taken 102656 times.
✓ Branch 1 taken 401 times.
103057 for(int32_t i = 0; i < numsubscripts; i++)
12263 {
12264 102656 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12265
12266
1/2
✓ Branch 0 taken 102656 times.
✗ Branch 1 not taken.
102656 if (ret)
12267 {
12268 return qe_invalid;
12269 }
12270 102656 }
12271 401 }
12272 604 }
12273
12274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(s_version > 2)
12275 {
12276 int32_t bufsize;
12277 604 p_igetl(&bufsize, f);
12278
2/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
604 if (bufsize < 0 || bufsize > 1024*1024*10)
12279 {
12280 // God help anyone storing more than 10MB of code in the script buffer.
12281 return qe_invalid;
12282 }
12283 604 char * buf = new char[bufsize+1];
12284 604 pfread(buf, bufsize, f);
12285 604 buf[bufsize]=0;
12286
12287
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 zScript = string(buf);
12288
12289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 delete[] buf;
12290 word numffcbindings;
12291 604 p_igetw(&numffcbindings, f);
12292
12293
2/2
✓ Branch 0 taken 9617 times.
✓ Branch 1 taken 604 times.
10221 for(int32_t i=0; i<numffcbindings; i++)
12294 {
12295 word id;
12296 9617 p_igetw(&id, f);
12297 9617 p_igetl(&bufsize, f);
12298
2/4
✓ Branch 0 taken 9617 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9617 times.
9617 if (bufsize < 0 || bufsize > 1024)
12299 return qe_invalid;
12300 9617 buf = new char[bufsize+1];
12301 9617 pfread(buf, bufsize, f);
12302 9617 buf[bufsize]=0;
12303
12304 //fix for buggy older saved quests -DD
12305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9617 times.
9617 if(id < NUMSCRIPTFFC-1)
12306 9617 ffcmap[id].scriptname = buf;
12307
12308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9617 times.
9617 delete[] buf;
12309 9617 }
12310
12311 word numglobalbindings;
12312 604 p_igetw(&numglobalbindings, f);
12313
12314
2/2
✓ Branch 0 taken 1745 times.
✓ Branch 1 taken 604 times.
2349 for(int32_t i=0; i<numglobalbindings; i++)
12315 {
12316 word id;
12317 1745 p_igetw(&id, f);
12318 1745 p_igetl(&bufsize, f);
12319
2/4
✓ Branch 0 taken 1745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1745 times.
✗ Branch 3 not taken.
1745 if (bufsize < 0 || bufsize > 1024)
12320 return qe_invalid;
12321 1745 buf = new char[bufsize+1];
12322 1745 pfread(buf, bufsize, f);
12323 1745 buf[bufsize]=0;
12324
12325 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12326 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12327 // Ignore these. -DD
12328
3/4
✓ Branch 0 taken 1745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 540 times.
✓ Branch 3 taken 1205 times.
1745 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12329 {
12330 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12331
1/2
✓ Branch 0 taken 1205 times.
✗ Branch 1 not taken.
1205 if(strcmp(buf,"~Continue") == 0)
12332 {
12333 globalmap[id].scriptname = "";
12334
12335 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12336 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12337 }
12338 else
12339 {
12340 1205 globalmap[id].scriptname = buf;
12341 }
12342 1205 }
12343
12344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1745 times.
1745 delete[] buf;
12345 1745 }
12346
12347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(s_version > 3)
12348 {
12349 word numitembindings;
12350 604 p_igetw(&numitembindings, f);
12351
12352
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 604 times.
1751 for(int32_t i=0; i<numitembindings; i++)
12353 {
12354 word id;
12355 1147 p_igetw(&id, f);
12356 1147 p_igetl(&bufsize, f);
12357
2/4
✓ Branch 0 taken 1147 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1147 times.
1147 if (bufsize < 0 || bufsize > 1024)
12358 return qe_invalid;
12359 1147 buf = new char[bufsize+1];
12360 1147 pfread(buf, bufsize, f);
12361 1147 buf[bufsize]=0;
12362
12363 //fix this too
12364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1147 times.
1147 if(id <NUMSCRIPTITEM-1)
12365 1147 itemmap[id].scriptname = buf;
12366
12367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1147 times.
1147 delete[] buf;
12368 1147 }
12369 604 }
12370 //(v9+)
12371
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version > 8)
12372 {
12373 //npc scripts
12374 word numnpcbindings;
12375 419 p_igetw(&numnpcbindings, f);
12376
12377
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 419 times.
450 for(int32_t i=0; i<numnpcbindings; i++)
12378 {
12379 word id;
12380 31 p_igetw(&id, f);
12381 31 p_igetl(&bufsize, f);
12382
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if (bufsize < 0 || bufsize > 1024)
12383 return qe_invalid;
12384 31 buf = new char[bufsize+1];
12385 31 pfread(buf, bufsize, f);
12386 31 buf[bufsize]=0;
12387
12388 //fix this too
12389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(id <NUMSCRIPTGUYS-1)
12390 31 npcmap[id].scriptname = buf;
12391
12392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 delete[] buf;
12393 31 }
12394 //lweapon
12395 word numlwpnbindings;
12396 419 p_igetw(&numlwpnbindings, f);
12397
12398
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 419 times.
632 for(int32_t i=0; i<numlwpnbindings; i++)
12399 {
12400 word id;
12401 213 p_igetw(&id, f);
12402 213 p_igetl(&bufsize, f);
12403
2/4
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
213 if (bufsize < 0 || bufsize > 1024)
12404 return qe_invalid;
12405 213 buf = new char[bufsize+1];
12406 213 pfread(buf, bufsize, f);
12407 213 buf[bufsize]=0;
12408
12409 //fix this too
12410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 if(id <NUMSCRIPTWEAPONS-1)
12411 213 lwpnmap[id].scriptname = buf;
12412
12413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 delete[] buf;
12414 213 }
12415 //eweapon
12416 word numewpnbindings;
12417 419 p_igetw(&numewpnbindings, f);
12418
12419
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 419 times.
699 for(int32_t i=0; i<numewpnbindings; i++)
12420 {
12421 word id;
12422 280 p_igetw(&id, f);
12423 280 p_igetl(&bufsize, f);
12424
2/4
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
280 if (bufsize < 0 || bufsize > 1024)
12425 return qe_invalid;
12426 280 buf = new char[bufsize+1];
12427 280 pfread(buf, bufsize, f);
12428 280 buf[bufsize]=0;
12429
12430 //fix this too
12431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(id <NUMSCRIPTWEAPONS-1)
12432 280 ewpnmap[id].scriptname = buf;
12433
12434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 delete[] buf;
12435 280 }
12436 //hero
12437 word numherobindings;
12438 419 p_igetw(&numherobindings, f);
12439
12440
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 419 times.
440 for(int32_t i=0; i<numherobindings; i++)
12441 {
12442 word id;
12443 21 p_igetw(&id, f);
12444 21 p_igetl(&bufsize, f);
12445
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if (bufsize < 0 || bufsize > 1024)
12446 return qe_invalid;
12447 21 buf = new char[bufsize+1];
12448 21 pfread(buf, bufsize, f);
12449 21 buf[bufsize]=0;
12450
12451 //fix this too
12452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(id <NUMSCRIPTPLAYER-1)
12453 21 playermap[id].scriptname = buf;
12454
12455
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 delete[] buf;
12456 21 }
12457 //dmaps
12458 word numdmapbindings;
12459 419 p_igetw(&numdmapbindings, f);
12460
12461
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 419 times.
674 for(int32_t i=0; i<numdmapbindings; i++)
12462 {
12463 word id;
12464 255 p_igetw(&id, f);
12465 255 p_igetl(&bufsize, f);
12466
2/4
✓ Branch 0 taken 255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
255 if (bufsize < 0 || bufsize > 1024)
12467 return qe_invalid;
12468 255 buf = new char[bufsize+1];
12469 255 pfread(buf, bufsize, f);
12470 255 buf[bufsize]=0;
12471
12472 //fix this too
12473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if(id <NUMSCRIPTSDMAP-1)
12474 255 dmapmap[id].scriptname = buf;
12475
12476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 delete[] buf;
12477 255 }
12478 //screen
12479 word numscreenbindings;
12480 419 p_igetw(&numscreenbindings, f);
12481
12482
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 419 times.
752 for(int32_t i=0; i<numscreenbindings; i++)
12483 {
12484 word id;
12485 333 p_igetw(&id, f);
12486 333 p_igetl(&bufsize, f);
12487
2/4
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
333 if (bufsize < 0 || bufsize > 1024)
12488 return qe_invalid;
12489 333 buf = new char[bufsize+1];
12490 333 pfread(buf, bufsize, f);
12491 333 buf[bufsize]=0;
12492
12493 //fix this too
12494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if(id <NUMSCRIPTSDMAP-1)
12495 333 screenmap[id].scriptname = buf;
12496
12497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 delete[] buf;
12498 333 }
12499 419 }
12500
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version > 11)
12501 {
12502 word numspritebindings;
12503 419 p_igetw(&numspritebindings, f);
12504
12505
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 419 times.
463 for(int32_t i=0; i<numspritebindings; i++)
12506 {
12507 word id;
12508 44 p_igetw(&id, f);
12509 44 p_igetl(&bufsize, f);
12510
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
44 if (bufsize < 0 || bufsize > 1024)
12511 return qe_invalid;
12512 44 buf = new char[bufsize+1];
12513 44 pfread(buf, bufsize, f);
12514 44 buf[bufsize]=0;
12515
12516 //fix this too
12517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(id <NUMSCRIPTSDMAP-1)
12518 44 itemspritemap[id].scriptname = buf;
12519
12520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 delete[] buf;
12521 44 }
12522 419 }
12523
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version >= 15)
12524 {
12525 word numcombobindings;
12526 419 p_igetw(&numcombobindings, f);
12527
12528
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 419 times.
562 for(int32_t i=0; i<numcombobindings; i++)
12529 {
12530 word id;
12531 143 p_igetw(&id, f);
12532 143 p_igetl(&bufsize, f);
12533
2/4
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
143 if (bufsize < 0 || bufsize > 1024)
12534 return qe_invalid;
12535 143 buf = new char[bufsize+1];
12536 143 pfread(buf, bufsize, f);
12537 143 buf[bufsize]=0;
12538
12539 //fix this too
12540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(id <NUMSCRIPTSCOMBODATA-1)
12541 143 comboscriptmap[id].scriptname = buf;
12542
12543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 delete[] buf;
12544 143 }
12545 419 }
12546
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if(s_version > 19)
12547 {
12548 word numgenericbindings;
12549 419 p_igetw(&numgenericbindings, f);
12550
12551
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 419 times.
522 for(int32_t i=0; i<numgenericbindings; i++)
12552 {
12553 word id;
12554 103 p_igetw(&id, f);
12555 103 p_igetl(&bufsize, f);
12556
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (bufsize < 0 || bufsize > 1024)
12557 return qe_invalid;
12558 103 buf = new char[bufsize+1];
12559 103 pfread(buf, bufsize, f);
12560 103 buf[bufsize]=0;
12561
12562 //fix this too
12563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(id <NUMSCRIPTSGENERIC-1)
12564 103 genericmap[id].scriptname = buf;
12565
12566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 delete[] buf;
12567 103 }
12568 419 }
12569
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 401 times.
604 if(s_version > 21)
12570 {
12571 word numsubscreenbindings;
12572 401 p_igetw(&numsubscreenbindings, f);
12573
12574
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 401 times.
408 for(int32_t i=0; i<numsubscreenbindings; i++)
12575 {
12576 word id;
12577 7 p_igetw(&id, f);
12578 7 p_igetl(&bufsize, f);
12579
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if (bufsize < 0 || bufsize > 1024)
12580 return qe_invalid;
12581 7 buf = new char[bufsize+1];
12582 7 pfread(buf, bufsize, f);
12583 7 buf[bufsize]=0;
12584
12585 //fix this too
12586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(id <NUMSCRIPTSSUBSCREEN-1)
12587 7 subscreenmap[id].scriptname = buf;
12588
12589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 delete[] buf;
12590 7 }
12591 401 }
12592 604 }
12593
12594 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12595 // This is only updated when the scripts have been recompiled.
12596 // They should all match each other.
12597 604 std::optional<word> zscript_version;
12598
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 419 times.
604 if (s_version >= 16)
12599 {
12600
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 for (auto script : read_scripts)
12601 {
12602 if (script->meta.ffscript_v == 0 || script->meta.ffscript_v > s_version)
12603 break;
12604
12605 if (!zscript_version.has_value())
12606 {
12607 zscript_version = script->meta.ffscript_v;
12608 continue;
12609 }
12610
12611 if (zscript_version.value() != script->meta.ffscript_v)
12612 {
12613 zscript_version.reset();
12614 break;
12615 }
12616 }
12617
12618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if (!zscript_version.has_value())
12619 419 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12620 419 }
12621 604 setZScriptVersion(zscript_version.value_or(s_version));
12622 604 read_scripts.clear();
12623
12624 604 return 0;
12625 604 }
12626
12627 686 void reset_scripts()
12628 {
12629 #ifdef IS_PLAYER
12630 // We can't modify the script data while jit threads are possibly compiling them.
12631 void jit_shutdown();
12632 678 jit_shutdown();
12633 #endif
12634
12635
2/2
✓ Branch 0 taken 351232 times.
✓ Branch 1 taken 686 times.
351918 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12636 {
12637
1/2
✓ Branch 0 taken 351232 times.
✗ Branch 1 not taken.
351232 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12638 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12639 351232 }
12640
12641
2/2
✓ Branch 0 taken 351232 times.
✓ Branch 1 taken 686 times.
351918 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12642 {
12643
1/2
✓ Branch 0 taken 351232 times.
✗ Branch 1 not taken.
351232 if (ffscripts[i])
12644 351232 ffscripts[i]->disable();
12645 else
12646 ffscripts[i] = new script_data(ScriptType::FFC, i);
12647 351232 }
12648
12649
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12650 {
12651
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (itemscripts[i])
12652 175616 itemscripts[i]->disable();
12653 else
12654 itemscripts[i] = new script_data(ScriptType::Item, i);
12655 175616 }
12656
12657
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12658 {
12659
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (guyscripts[i])
12660 175616 guyscripts[i]->disable();
12661 else
12662 guyscripts[i] = new script_data(ScriptType::NPC, i);
12663 175616 }
12664
12665
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12666 {
12667
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (screenscripts[i])
12668 175616 screenscripts[i]->disable();
12669 else
12670 screenscripts[i] = new script_data(ScriptType::Screen, i);
12671 175616 }
12672
12673
2/2
✓ Branch 0 taken 5488 times.
✓ Branch 1 taken 686 times.
6174 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12674 {
12675
1/2
✓ Branch 0 taken 5488 times.
✗ Branch 1 not taken.
5488 if (globalscripts[i])
12676 5488 globalscripts[i]->disable();
12677 else
12678 globalscripts[i] = new script_data(ScriptType::Global, i);
12679 5488 }
12680
12681
2/2
✓ Branch 0 taken 3430 times.
✓ Branch 1 taken 686 times.
4116 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12682 {
12683
1/2
✓ Branch 0 taken 3430 times.
✗ Branch 1 not taken.
3430 if (playerscripts[i])
12684 3430 playerscripts[i]->disable();
12685 else
12686 playerscripts[i] = new script_data(ScriptType::Player, i);
12687 3430 }
12688
12689
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12690 {
12691
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (lwpnscripts[i])
12692 175616 lwpnscripts[i]->disable();
12693 else
12694 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12695 175616 }
12696
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12697 {
12698
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (ewpnscripts[i])
12699 175616 ewpnscripts[i]->disable();
12700 else
12701 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12702 175616 }
12703
12704
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12705 {
12706
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (dmapscripts[i])
12707 175616 dmapscripts[i]->disable();
12708 else
12709 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12710 175616 }
12711
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12712 {
12713
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (itemspritescripts[i])
12714 175616 itemspritescripts[i]->disable();
12715 else
12716 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12717 175616 }
12718
2/2
✓ Branch 0 taken 351232 times.
✓ Branch 1 taken 686 times.
351918 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12719 {
12720
1/2
✓ Branch 0 taken 351232 times.
✗ Branch 1 not taken.
351232 if (comboscripts[i])
12721 351232 comboscripts[i]->disable();
12722 else
12723 comboscripts[i] = new script_data(ScriptType::Combo, i);
12724 351232 }
12725
2/2
✓ Branch 0 taken 175616 times.
✓ Branch 1 taken 686 times.
176302 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12726 {
12727
1/2
✓ Branch 0 taken 175616 times.
✗ Branch 1 not taken.
175616 if (subscreenscripts[i])
12728 175616 subscreenscripts[i]->disable();
12729 else
12730 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12731 175616 }
12732 686 }
12733
12734 1895254 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12735 {
12736 // TODO: refactor to just take a script_data*
12737 ASSERT(*script);
12738
12739 //Please also update loadquest() when modifying this method -DD
12740 1895254 char b33[34] = {0};
12741 1895254 b33[33] = 0;
12742 1895254 int32_t num_commands=1000;
12743
12744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1895254 times.
1895254 if(s_version>=2)
12745 {
12746
1/2
✓ Branch 0 taken 1895254 times.
✗ Branch 1 not taken.
1895254 if(!p_igetl(&num_commands,f))
12747 {
12748 return qe_invalid;
12749 }
12750 1895254 }
12751
12752 #ifdef ZC_FUZZ
12753 const int32_t command_limit = 300000;
12754 #else
12755 1895254 const int32_t command_limit = 10000000;
12756 #endif
12757
2/4
✓ Branch 0 taken 1895254 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895254 times.
1895254 if (num_commands < 0 || num_commands > command_limit)
12758 {
12759 return qe_invalid;
12760 }
12761
12762 1895254 std::vector<ffscript> zasm;
12763
1/2
✓ Branch 0 taken 1895254 times.
✗ Branch 1 not taken.
1895254 zasm.reserve(num_commands);
12764
12765
2/2
✓ Branch 0 taken 1609799 times.
✓ Branch 1 taken 285455 times.
1895254 if(s_version >= 16)
12766 {
12767
1/2
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
1609799 zasm_meta temp_meta;
12768
12769
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.zasm_v),f))
12770 {
12771 return qe_invalid;
12772 }
12773
12774
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.meta_v),f))
12775 {
12776 return qe_invalid;
12777 }
12778
12779
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.ffscript_v),f))
12780 {
12781 return qe_invalid;
12782 }
12783
12784
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_getc(&(temp_meta.script_type),f))
12785 {
12786 return qe_invalid;
12787 }
12788
12789
2/2
✓ Branch 0 taken 12878392 times.
✓ Branch 1 taken 1609799 times.
14488191 for(int32_t q = 0; q < 8; ++q)
12790 {
12791
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 12734512 times.
12878392 if(zmeta_version < 3)
12792 {
12793
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
12794 {
12795
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
12796 {
12797 return qe_invalid;
12798 }
12799 4748040 }
12800
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
12801 143880 }
12802 else
12803 {
12804
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getcstr(&temp_meta.run_idens[q],f))
12805 {
12806 return qe_invalid;
12807 }
12808 }
12809 12878392 }
12810
12811
2/2
✓ Branch 0 taken 1609799 times.
✓ Branch 1 taken 12878392 times.
14488191 for(int32_t q = 0; q < 8; ++q)
12812 {
12813
2/4
✓ Branch 0 taken 12878392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12878392 times.
✗ Branch 3 not taken.
12878392 if(!p_getc(&(temp_meta.run_types[q]),f))
12814 {
12815 return qe_invalid;
12816 }
12817 12878392 }
12818
12819
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_getc(&(temp_meta.flags),f))
12820 {
12821 return qe_invalid;
12822 }
12823
12824
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.compiler_v1),f))
12825 {
12826 return qe_invalid;
12827 }
12828
12829
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.compiler_v2),f))
12830 {
12831 return qe_invalid;
12832 }
12833
12834
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.compiler_v3),f))
12835 {
12836 return qe_invalid;
12837 }
12838
12839
2/4
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609799 times.
✗ Branch 3 not taken.
1609799 if(!p_igetw(&(temp_meta.compiler_v4),f))
12840 {
12841 return qe_invalid;
12842 }
12843
12844
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 1591814 times.
1609799 if(zmeta_version == 2)
12845 {
12846
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12847 {
12848
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12849 {
12850 return qe_invalid;
12851 }
12852 593505 }
12853
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
12854
12855
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12856 {
12857
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12858 {
12859 return qe_invalid;
12860 }
12861 593505 }
12862
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
12863 17985 }
12864
1/2
✓ Branch 0 taken 1591814 times.
✗ Branch 1 not taken.
1591814 else if(zmeta_version > 2)
12865 {
12866
2/4
✓ Branch 0 taken 1591814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1591814 times.
✗ Branch 3 not taken.
1591814 if(!p_getcstr(&temp_meta.script_name,f))
12867 return qe_invalid;
12868
2/4
✓ Branch 0 taken 1591814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1591814 times.
✗ Branch 3 not taken.
1591814 if(!p_getcstr(&temp_meta.author,f))
12869 return qe_invalid;
12870 1591814 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12871
2/2
✓ Branch 0 taken 15918140 times.
✓ Branch 1 taken 1591814 times.
17509954 for(auto q = 0; q < num_meta_attrib; ++q)
12872 {
12873
2/4
✓ Branch 0 taken 15918140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15918140 times.
✗ Branch 3 not taken.
15918140 if(!p_getcstr(&temp_meta.attributes[q],f))
12874 return qe_invalid;
12875
2/4
✓ Branch 0 taken 15918140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15918140 times.
✗ Branch 3 not taken.
15918140 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12876 return qe_invalid;
12877 15918140 }
12878
2/2
✓ Branch 0 taken 12734512 times.
✓ Branch 1 taken 1591814 times.
14326326 for(auto q = 0; q < 8; ++q)
12879 {
12880
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getcstr(&temp_meta.attribytes[q],f))
12881 return qe_invalid;
12882
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12883 return qe_invalid;
12884 12734512 }
12885
2/2
✓ Branch 0 taken 12734512 times.
✓ Branch 1 taken 1591814 times.
14326326 for(auto q = 0; q < 8; ++q)
12886 {
12887
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12888 return qe_invalid;
12889
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12890 return qe_invalid;
12891 12734512 }
12892
2/2
✓ Branch 0 taken 25469024 times.
✓ Branch 1 taken 1591814 times.
27060838 for(auto q = 0; q < 16; ++q)
12893 {
12894
2/4
✓ Branch 0 taken 25469024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25469024 times.
✗ Branch 3 not taken.
25469024 if(!p_getcstr(&temp_meta.usrflags[q],f))
12895 return qe_invalid;
12896
2/4
✓ Branch 0 taken 25469024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25469024 times.
✗ Branch 3 not taken.
25469024 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12897 return qe_invalid;
12898 25469024 }
12899 1591814 }
12900
2/2
✓ Branch 0 taken 1591814 times.
✓ Branch 1 taken 17985 times.
1609799 if(zmeta_version > 3)
12901 {
12902
2/2
✓ Branch 0 taken 12734512 times.
✓ Branch 1 taken 1591814 times.
14326326 for(auto q = 0; q < 8; ++q)
12903 {
12904
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getcstr(&temp_meta.initd[q],f))
12905 return qe_invalid;
12906
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getwstr(&temp_meta.initd_help[q],f))
12907 return qe_invalid;
12908 12734512 }
12909
2/2
✓ Branch 0 taken 12734512 times.
✓ Branch 1 taken 1591814 times.
14326326 for(auto q = 0; q < 8; ++q)
12910 {
12911
2/4
✓ Branch 0 taken 12734512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12734512 times.
✗ Branch 3 not taken.
12734512 if(!p_getc(&temp_meta.initd_type[q],f))
12912 return qe_invalid;
12913 12734512 }
12914 1591814 }
12915 else
12916 {
12917
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
12918 {
12919
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
12920 143880 }
12921 }
12922
12923
1/2
✓ Branch 0 taken 1609799 times.
✗ Branch 1 not taken.
1609799 (*script)->meta = temp_meta;
12924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1609799 times.
1609799 }
12925
12926
2/2
✓ Branch 0 taken 93763311 times.
✓ Branch 1 taken 136887 times.
93900198 for(int32_t j=0; j<num_commands; j++)
12927 {
12928
1/2
✓ Branch 0 taken 93763311 times.
✗ Branch 1 not taken.
93763311 auto& sc = zasm.emplace_back();
12929
2/4
✓ Branch 0 taken 93763311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93763311 times.
✗ Branch 3 not taken.
93763311 if(!p_igetw(&sc.command,f))
12930 {
12931 return qe_invalid;
12932 }
12933
12934
2/2
✓ Branch 0 taken 92004944 times.
✓ Branch 1 taken 1758367 times.
93763311 if(sc.command == 0xFFFF)
12935 {
12936 1758367 break;
12937 }
12938
12939
2/4
✓ Branch 0 taken 92004944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92004944 times.
✗ Branch 3 not taken.
92004944 if(!p_igetl(&sc.arg1,f))
12940 {
12941 return qe_invalid;
12942 }
12943
12944
2/4
✓ Branch 0 taken 92004944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92004944 times.
✗ Branch 3 not taken.
92004944 if(!p_igetl(&sc.arg2,f))
12945 {
12946 return qe_invalid;
12947 }
12948
12949
2/2
✓ Branch 0 taken 2315671 times.
✓ Branch 1 taken 89689273 times.
92004944 if(s_version >= 24)
12950
2/4
✓ Branch 0 taken 2315671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2315671 times.
✗ Branch 3 not taken.
2315671 if(!p_igetl(&sc.arg3,f))
12951 return qe_invalid;
12952
12953
2/2
✓ Branch 0 taken 8571398 times.
✓ Branch 1 taken 83433546 times.
92004944 if(s_version >= 21)
12954 {
12955 8571398 uint32_t sz = 0;
12956
2/4
✓ Branch 0 taken 8571398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8571398 times.
✗ Branch 3 not taken.
8571398 if(!p_igetl(&sz,f))
12957 {
12958 return qe_invalid;
12959 }
12960
2/2
✓ Branch 0 taken 34114 times.
✓ Branch 1 taken 8537284 times.
8571398 if(sz) //string found
12961 {
12962
1/2
✓ Branch 0 taken 34114 times.
✗ Branch 1 not taken.
34114 sc.strptr = new std::string();
12963 char dummy;
12964
2/2
✓ Branch 0 taken 1312395 times.
✓ Branch 1 taken 34114 times.
1346509 for(size_t q = 0; q < sz; ++q)
12965 {
12966
2/4
✓ Branch 0 taken 1312395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1312395 times.
✗ Branch 3 not taken.
1312395 if(!p_getc(&dummy,f))
12967 {
12968 return qe_invalid;
12969 }
12970
1/2
✓ Branch 0 taken 1312395 times.
✗ Branch 1 not taken.
1312395 sc.strptr->push_back(dummy);
12971 1312395 }
12972 34114 }
12973
2/4
✓ Branch 0 taken 8571398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8571398 times.
✗ Branch 3 not taken.
8571398 if(!p_igetl(&sz,f))
12974 {
12975 return qe_invalid;
12976 }
12977
2/2
✓ Branch 0 taken 2251 times.
✓ Branch 1 taken 8569147 times.
8571398 if(sz) //vector found
12978 {
12979
1/2
✓ Branch 0 taken 2251 times.
✗ Branch 1 not taken.
2251 sc.vecptr = new std::vector<int32_t>();
12980 int32_t dummy;
12981
2/2
✓ Branch 0 taken 14896 times.
✓ Branch 1 taken 2251 times.
17147 for(size_t q = 0; q < sz; ++q)
12982 {
12983
2/4
✓ Branch 0 taken 14896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14896 times.
✗ Branch 3 not taken.
14896 if(!p_igetl(&dummy,f))
12984 {
12985 return qe_invalid;
12986 }
12987
1/2
✓ Branch 0 taken 14896 times.
✗ Branch 1 not taken.
14896 sc.vecptr->push_back(dummy);
12988 14896 }
12989 2251 }
12990 8571398 }
12991 92004944 }
12992
12993 // If the first command is unknown, invalidate the whole thing.
12994 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
12995
5/6
✓ Branch 0 taken 1758367 times.
✓ Branch 1 taken 136887 times.
✓ Branch 2 taken 1745198 times.
✓ Branch 3 taken 13169 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1745198 times.
1895254 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
12996 {
12997 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString((*script)->id.type), (*script)->id.index);
12998 zasm.clear();
12999 }
13000
13001 1895254 zasm_script_id id = zasm_scripts.size();
13002
3/6
✓ Branch 0 taken 1895254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1895254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1895254 times.
✗ Branch 5 not taken.
1895254 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, (*script)->name(), std::move(zasm)));
13003 1895254 (*script)->zasm_script = zs;
13004
13005 1895254 return 0;
13006 1895254 }
13007
13008 extern SAMPLE customsfxdata[WAV_COUNT];
13009 extern uint8_t customsfxflag[WAV_COUNT>>3];
13010 extern int32_t sfxdat;
13011 extern DATAFILE *sfxdata;
13012 const char *old_sfx_string[Z35] =
13013 {
13014 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13015 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13016 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13017 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13018 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13019 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13020 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13021 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13022 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13023 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13024 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13025 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13026 };
13027 char *sfx_string[WAV_COUNT];
13028
13029 604 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13030 {
13031 //these are here to bypass compiler warnings about unused arguments
13032 604 Header=Header;
13033
13034 int32_t dummy;
13035 604 word s_version=0, s_cversion=0;
13036 //int32_t ret;
13037 604 SAMPLE temp_sample = {};
13038 604 temp_sample.loop_start=0;
13039 604 temp_sample.loop_end=0;
13040 604 temp_sample.param=0;
13041
13042 //section version info
13043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_igetw(&s_version,f))
13044 {
13045 return qe_invalid;
13046 }
13047
13048 604 FFCore.quest_format[vSFX] = s_version;
13049
13050 //al_trace("SFX version %d\n", s_version);
13051
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
13052 {
13053 return qe_invalid;
13054 }
13055
13056 //section size
13057
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&dummy,f))
13058 {
13059 return qe_invalid;
13060 }
13061
13062 /* HIGHLY UNORTHODOX UPDATING THING, by L
13063 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13064 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13065 * changing from 1 to 2.
13066 */
13067
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(s_version < 2)
13068 set_qr(qr_GOTOLESSNOTEQUAL,1);
13069
13070 /* End highly unorthodox updating thing */
13071
13072 604 int32_t wavcount = WAV_COUNT;
13073
13074
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(s_version < 6)
13075 wavcount = 128;
13076
13077 uint8_t tempflag[WAV_COUNT>>3];
13078
13079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(s_version < 4)
13080 {
13081 memset(tempflag, 0xFF, WAV_COUNT>>3);
13082 }
13083 else
13084 {
13085
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(s_version < 6)
13086 memset(tempflag, 0, WAV_COUNT>>3);
13087
13088
2/2
✓ Branch 0 taken 19328 times.
✓ Branch 1 taken 604 times.
19932 for(int32_t i=0; i<(wavcount>>3); i++)
13089 {
13090 19328 p_getc(&tempflag[i], f);
13091 19328 }
13092
13093 }
13094
13095
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(s_version>4)
13096 {
13097
2/2
✓ Branch 0 taken 154020 times.
✓ Branch 1 taken 604 times.
154624 for(int32_t i=1; i<WAV_COUNT; i++)
13098 {
13099 154020 sprintf(sfx_string[i],"s%03d",i);
13100
13101
2/2
✓ Branch 0 taken 117780 times.
✓ Branch 1 taken 36240 times.
154020 if((i<Z35))
13102 36240 strcpy(sfx_string[i], old_sfx_string[i-1]);
13103
13104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154020 times.
154020 if(i>=wavcount)
13105 continue;
13106
2/2
✓ Branch 0 taken 35548 times.
✓ Branch 1 taken 118472 times.
154020 if(get_bit(tempflag, i-1))
13107 {
13108 char tempname[36];
13109
13110
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!pfread(tempname, 36, f))
13111 {
13112 return qe_invalid;
13113 }
13114
13115 35548 sfx_string[i][0] = '\0';
13116 35548 strncat(sfx_string[i], tempname, 36 - 1);
13117 35548 }
13118 else
13119 {
13120 118472 sprintf(sfx_string[i],"s%03d",i);
13121
13122
2/2
✓ Branch 0 taken 109384 times.
✓ Branch 1 taken 9088 times.
118472 if(i<Z35)
13123 9088 strcpy(sfx_string[i], old_sfx_string[i-1]);
13124 118472 sfx_string[i][35] = 0; //Force NULL Termination
13125 }
13126 154020 }
13127 604 }
13128 else
13129 {
13130 for(int32_t i=1; i<WAV_COUNT; i++)
13131 {
13132 sprintf(sfx_string[i],"s%03d",i);
13133
13134 if(i<Z35)
13135 strcpy(sfx_string[i], old_sfx_string[i-1]);
13136 }
13137 }
13138
13139 //finally... section data
13140
2/2
✓ Branch 0 taken 154020 times.
✓ Branch 1 taken 604 times.
154624 for(int32_t i=1; i<wavcount; i++)
13141 {
13142
2/2
✓ Branch 0 taken 35548 times.
✓ Branch 1 taken 118472 times.
154020 if(get_bit(tempflag, i-1))
13143 {
13144
13145
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&dummy,f))
13146 {
13147 return qe_invalid;
13148 }
13149
13150 35548 (temp_sample.bits) = dummy;
13151
13152
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&dummy,f))
13153 {
13154 return qe_invalid;
13155 }
13156
13157 35548 (temp_sample.stereo) = dummy;
13158
13159
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&dummy,f))
13160 {
13161 return qe_invalid;
13162 }
13163
13164 35548 (temp_sample.freq) = dummy;
13165
13166
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&dummy,f))
13167 {
13168 return qe_invalid;
13169 }
13170
13171 35548 (temp_sample.priority) = dummy;
13172
13173
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&(temp_sample.len),f))
13174 {
13175 return qe_invalid;
13176 }
13177
13178
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&(temp_sample.loop_start),f))
13179 {
13180 return qe_invalid;
13181 }
13182
13183
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&(temp_sample.loop_end),f))
13184 {
13185 return qe_invalid;
13186 }
13187
13188
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(!p_igetl(&(temp_sample.param),f))
13189 {
13190 return qe_invalid;
13191 }
13192
13193 // al_trace("F%i: L%i\n",i,temp_sample.len);
13194 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13195 35548 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13196
2/4
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35548 times.
35548 if (len < 0 || len > 10000000)
13197 {
13198 return qe_invalid;
13199 }
13200 35548 temp_sample.data = calloc(len,1);
13201
13202
1/2
✓ Branch 0 taken 35548 times.
✗ Branch 1 not taken.
35548 if(s_version < 3)
13203 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13204
13205 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35548 times.
35548 if(s_version < 2)
13207 {
13208 if(!pfread(temp_sample.data, len,f))
13209 {
13210 return qe_invalid;
13211 }
13212 }
13213 else
13214 {
13215 //re-endianfy the data
13216 35548 int32_t wordstoread = len / sizeof(word);
13217
13218
2/2
✓ Branch 0 taken 970318813 times.
✓ Branch 1 taken 35548 times.
970354361 for(int32_t j=0; j<wordstoread; j++)
13219 {
13220 word temp;
13221
13222
1/2
✓ Branch 0 taken 970318813 times.
✗ Branch 1 not taken.
970318813 if(!p_igetw(&temp, f))
13223 {
13224 return qe_invalid;
13225 }
13226
13227 970318813 ((word *)temp_sample.data)[j] = temp;
13228 970318813 }
13229 }
13230 35548 }
13231
2/2
✓ Branch 0 taken 9088 times.
✓ Branch 1 taken 109384 times.
118472 else if(i < Z35)
13232 {
13233 9088 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13234 9088 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13235 9088 set_bit(tempflag, i-1, 1);
13236 9088 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13237 9088 temp_sample.data = calloc(len,1);
13238 9088 memcpy(temp_sample.data, datsamp->data, len);
13239 9088 }
13240 109384 else continue;
13241
13242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44636 times.
44636 if(customsfxdata[i].data!=NULL)
13243 {
13244 // delete [] customsfxdata[i].data;
13245 44636 free(customsfxdata[i].data);
13246 44636 }
13247
13248 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13249 44636 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13250 44636 customsfxdata[i].data = calloc(len2,1);
13251 44636 customsfxdata[i].bits = temp_sample.bits;
13252 44636 customsfxdata[i].stereo = temp_sample.stereo;
13253 44636 customsfxdata[i].freq = temp_sample.freq;
13254 44636 customsfxdata[i].priority = temp_sample.priority;
13255 44636 customsfxdata[i].len = temp_sample.len;
13256 44636 customsfxdata[i].loop_start = temp_sample.loop_start;
13257 44636 customsfxdata[i].loop_end = temp_sample.loop_end;
13258 44636 customsfxdata[i].param = temp_sample.param;
13259 44636 int32_t cpylen = len2;
13260
13261
1/2
✓ Branch 0 taken 44636 times.
✗ Branch 1 not taken.
44636 if(s_version<3)
13262 {
13263 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13264 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13265 }
13266
13267 44636 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13268
13269 44636 free(temp_sample.data);
13270 44636 }
13271
13272 604 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13273
13274 604 sfxdat=0;
13275 604 return 0;
13276 604 }
13277
13278 686 void setupsfx()
13279 {
13280
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=1; i<WAV_COUNT; i++)
13281 {
13282 174930 sprintf(sfx_string[i],"s%03d",i);
13283
13284
2/2
✓ Branch 0 taken 133770 times.
✓ Branch 1 taken 41160 times.
174930 if(i<Z35)
13285 {
13286 41160 strcpy(sfx_string[i], old_sfx_string[i-1]);
13287 41160 }
13288
13289 174930 memset(customsfxflag, 0, WAV_COUNT>>3);
13290
13291 174930 int32_t j=i;
13292
13293
2/2
✓ Branch 0 taken 41846 times.
✓ Branch 1 taken 133084 times.
174930 if(i>Z35)
13294 {
13295 133084 i=Z35;
13296 133084 }
13297
13298 174930 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13299
13300
2/2
✓ Branch 0 taken 78540 times.
✓ Branch 1 taken 96390 times.
174930 if(customsfxdata[j].data!=NULL)
13301 {
13302 // delete [] customsfxdata[j].data;
13303 96390 free(customsfxdata[j].data);
13304 96390 }
13305
13306 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13307 174930 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13308 174930 customsfxdata[j].bits = temp_sample->bits;
13309 174930 customsfxdata[j].stereo = temp_sample->stereo;
13310 174930 customsfxdata[j].freq = temp_sample->freq;
13311 174930 customsfxdata[j].priority = temp_sample->priority;
13312 174930 customsfxdata[j].len = temp_sample->len;
13313 174930 customsfxdata[j].loop_start = temp_sample->loop_start;
13314 174930 customsfxdata[j].loop_end = temp_sample->loop_end;
13315 174930 customsfxdata[j].param = temp_sample->param;
13316 174930 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13317 174930 i=j;
13318 174930 }
13319 686 }
13320
13321 extern char *guy_string[eMAXGUYS];
13322 extern const char *old_guy_string[OLDMAXGUYS];
13323
13324 686 int32_t readguys(PACKFILE *f, zquestheader *Header)
13325 {
13326
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 if (should_skip) return 0;
13328
13329 dword dummy;
13330 word guy_cversion;
13331 686 word guyversion=0;
13332
13333
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 663 times.
686 if(Header->zelda_version >= 0x193)
13334 {
13335 //section version info
13336
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&guyversion,f))
13337 {
13338 return qe_invalid;
13339 }
13340
13341 663 FFCore.quest_format[vGuys] = guyversion;
13342
13343 //al_trace("Guys version %d\n", guyversion);
13344
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&guy_cversion,f))
13345 {
13346 return qe_invalid;
13347 }
13348 663 al_trace("Guy CVersion is: %d\n", guy_cversion);
13349 //section size
13350
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
13351 {
13352 return qe_invalid;
13353 }
13354 663 }
13355
13356
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(guyversion > 3)
13357 {
13358
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 604 times.
309852 for(int32_t i=0; i<MAXGUYS; i++)
13359 {
13360 char tempname[64];
13361
13362 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13363 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 309248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
309248 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13365 {
13366 memset(tempname, 0, sizeof(char)*64);
13367 sprintf(tempname, "e%03d", i);
13368 strcpy(guy_string[i], tempname);
13369
13370 continue;
13371 }
13372
13373
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!pfread(tempname, 64, f))
13374 {
13375 return qe_invalid;
13376 }
13377
13378 // Don't retain names of uneditable enemy entries!
13379 // for version upgrade to 2.5
13380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 309248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
309248 if(guyversion < 23 && i >= 177)
13381 {
13382 // some of the older builds have names such as 'zz123',
13383 // (this order gets messed up with some eXXX and some zzXXX)
13384 // so let's update to the newer naming convection. -Gleeok
13385 char tmpbuf[64];
13386 memset(tmpbuf, 0, sizeof(char)*64);
13387 sprintf(tmpbuf, "zz%03d", i);
13388
13389 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13390 {
13391 memset(tempname, 0, sizeof(char)*64);
13392 sprintf(tempname, "e%03d", i);
13393 }
13394 }
13395
13396
6/6
✓ Branch 0 taken 106908 times.
✓ Branch 1 taken 202340 times.
✓ Branch 2 taken 101472 times.
✓ Branch 3 taken 5436 times.
✓ Branch 4 taken 92432 times.
✓ Branch 5 taken 9040 times.
309248 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13397 {
13398 300208 guy_string[i][0] = '\0';
13399 300208 strncat(guy_string[i], tempname, 64 - 1);
13400 300208 }
13401 else
13402 {
13403 9040 strcpy(guy_string[i],old_guy_string[i]);
13404 }
13405 309248 }
13406 604 }
13407 else
13408 {
13409
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13410 {
13411 41984 sprintf(guy_string[i],"zz%03d",i);
13412 41984 }
13413
13414
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13415 {
13416 14514 strcpy(guy_string[i],old_guy_string[i]);
13417 14514 }
13418 }
13419
13420
13421 //finally... section data
13422 686 init_guys(guyversion); //using default data for now...
13423
13424 // Goriya guy fix
13425
3/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
686 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13426 {
13427
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13428 {
13429 60 guysbuf[gGORIYA].tile=130;
13430 60 guysbuf[gGORIYA].e_tile=130;
13431 60 }
13432 82 }
13433
13434
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 if(Header->zelda_version < 0x193)
13435 {
13436
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13437 {
13438 5 guysbuf[eDODONGO].cset=14;
13439 5 guysbuf[eDODONGO].bosspal=spDIG;
13440 5 }
13441 23 }
13442 // Not sure when this first changed, but it's necessary for 2.10, at least
13443 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13444 //2.10 Fixes
13445
3/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
686 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13446 {
13447 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13448 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13449 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13450 82 guysbuf[eCENT1].misc3 = 1;
13451 82 guysbuf[eCENT2].misc3 = 1;
13452 82 }
13453
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
686 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13454 {
13455 686 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13456 686 }
13457
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(Header->zelda_version <= 0x210)
13458 {
13459 82 guysbuf[eGLEEOK1F].misc6 = 16;
13460 82 guysbuf[eGLEEOK2F].misc6 = 16;
13461 82 guysbuf[eGLEEOK3F].misc6 = 16;
13462 82 guysbuf[eGLEEOK4F].misc6 = 16;
13463
13464 82 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13465 82 guysbuf[eBATROBE].misc4 = 1;
13466 //guysbuf[eSUMMONER].misc4 = 1;
13467 82 guysbuf[eWWIZ].misc4 = 1;
13468 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13469 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13470 82 }
13471
2/2
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 12 times.
686 if(Header->zelda_version == 0x190)
13472 {
13473 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13474 12 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13475 12 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13476 12 }
13477
13478 // The versions here may not be correct
13479 // zelda_version>=0x211 handled at guyversion<24
13480
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 668 times.
686 if(Header->zelda_version <= 0x190)
13481 {
13482 18 guysbuf[eCENT1].misc3 = 0;
13483 18 guysbuf[eCENT2].misc3 = 0;
13484 18 guysbuf[eMOLDORM].misc2 = 0;
13485 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13486 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13487 18 }
13488
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 64 times.
668 else if(Header->zelda_version <= 0x210)
13489 {
13490 64 guysbuf[eCENT1].misc3 = 1;
13491 64 guysbuf[eCENT2].misc3 = 1;
13492 64 guysbuf[eMOLDORM].misc2 = 0;
13493 64 }
13494
13495
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13496 {
13497 82 guysbuf[eKEESE1].misc16 = 120;
13498 82 guysbuf[eKEESE2].misc16 = 120;
13499 82 guysbuf[eKEESE3].misc16 = 120;
13500 82 guysbuf[eKEESETRIB].misc16 = 120;
13501 82 guysbuf[eKEESE1].misc17 = 16;
13502 82 guysbuf[eKEESE2].misc17 = 16;
13503 82 guysbuf[eKEESE3].misc17 = 16;
13504 82 guysbuf[eKEESETRIB].misc17 = 16;
13505
13506 82 guysbuf[ePEAHAT].misc16 = 80;
13507 82 guysbuf[ePEAHAT].misc17 = 16;
13508
13509 82 guysbuf[eGHINI2].misc16 = 120;
13510 82 guysbuf[eGHINI2].misc17 = 10;
13511
13512
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13513 {
13514 66 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13515 66 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13516 66 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13517 66 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13518 66 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13519 66 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13520 66 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13521 66 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13522 66 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13523 66 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13524 66 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13525 66 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13526 66 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13527 66 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13528 66 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13529 66 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13530 66 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13531 66 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13532 66 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13533 66 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13534 66 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13535 66 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13536 66 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13537 66 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13538 66 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13539 66 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13540 66 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13541 66 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13542 66 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13543 66 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13544 66 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13545 66 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13546 66 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13547 66 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13548 66 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13549 66 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13550 66 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13551 66 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13552 66 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13553 66 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13554 66 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13555 66 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13556 66 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13557 66 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13558 66 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13559 66 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13560 66 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13561 66 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13562 66 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13563 66 }
13564 82 }
13565
13566
13567
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 604 times.
686 if(guyversion<=2)
13568 {
13569 82 return readherosprites2(f, guyversion==2?0:-1, 0);
13570 }
13571
13572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(guyversion > 3)
13573 {
13574 guydata tempguy;
13575
13576
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 604 times.
309852 for(int32_t i=0; i<MAXGUYS; i++)
13577 {
13578
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 23) // May 2012 : 512 max enemies
13579 {
13580 if(i >= OLDBETAMAXGUYS)
13581 {
13582 memset(&guysbuf[i], 0, sizeof(guydata));
13583 continue;
13584 }
13585 }
13586
13587 309248 memset(&tempguy, 0, sizeof(guydata));
13588
13589
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.flags),f))
13590 {
13591 return qe_invalid;
13592 }
13593
13594
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.flags2),f))
13595 {
13596 return qe_invalid;
13597 }
13598
13599
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion >= 36 ) //expanded tiles
13600 {
13601
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.tile),f))
13602 {
13603 return qe_invalid;
13604 }
13605 214528 }
13606 else
13607 {
13608
1/2
✓ Branch 0 taken 94720 times.
✗ Branch 1 not taken.
94720 if(!p_igetw(&(tempguy.tile),f))
13609 {
13610 return qe_invalid;
13611 }
13612 }
13613
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.width),f))
13614 {
13615 return qe_invalid;
13616 }
13617
13618
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.height),f))
13619 {
13620 return qe_invalid;
13621 }
13622
13623
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion >= 36 ) //expanded tiles
13624 {
13625
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.s_tile),f))
13626 {
13627 return qe_invalid;
13628 }
13629 214528 }
13630 else
13631 {
13632
1/2
✓ Branch 0 taken 94720 times.
✗ Branch 1 not taken.
94720 if(!p_igetw(&(tempguy.s_tile),f))
13633 {
13634 return qe_invalid;
13635 }
13636 }
13637
13638
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.s_width),f))
13639 {
13640 return qe_invalid;
13641 }
13642
13643
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.s_height),f))
13644 {
13645 return qe_invalid;
13646 }
13647
13648
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion >= 36 ) //expanded tiles
13649 {
13650
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.e_tile),f))
13651 {
13652 return qe_invalid;
13653 }
13654 214528 }
13655 else
13656 {
13657
1/2
✓ Branch 0 taken 94720 times.
✗ Branch 1 not taken.
94720 if(!p_igetw(&(tempguy.e_tile),f))
13658 {
13659 return qe_invalid;
13660 }
13661 }
13662
13663
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.e_width),f))
13664 {
13665 return qe_invalid;
13666 }
13667
13668
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.e_height),f))
13669 {
13670 return qe_invalid;
13671 }
13672
13673
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.hp),f))
13674 {
13675 return qe_invalid;
13676 }
13677
13678
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.family),f))
13679 {
13680 return qe_invalid;
13681 }
13682
13683
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 309248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
309248 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13684 {
13685 if(get_qr(qr_NEWENEMYTILES))
13686 {
13687 tempguy.s_tile=tempguy.e_tile+120;
13688 tempguy.s_width=tempguy.e_width;
13689 tempguy.s_height=tempguy.e_height;
13690 }
13691 else tempguy.s_tile=860;
13692 }
13693
13694
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.cset),f))
13695 {
13696 return qe_invalid;
13697 }
13698
13699
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.anim),f))
13700 {
13701 return qe_invalid;
13702 }
13703
13704
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.e_anim),f))
13705 {
13706 return qe_invalid;
13707 }
13708
13709
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.frate),f))
13710 {
13711 return qe_invalid;
13712 }
13713
13714
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.e_frate),f))
13715 {
13716 return qe_invalid;
13717 }
13718
13719
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 13) // April 2009
13720 {
13721 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13722 {
13723 tempguy.frate *= 2;
13724 tempguy.e_frate *= 2;
13725 }
13726 }
13727
13728
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 14) // May 1 2009
13729 {
13730 if(tempguy.anim==a2FRMSLOW)
13731 {
13732 tempguy.anim=a2FRM;
13733 tempguy.frate *= 2;
13734 }
13735
13736 if(tempguy.e_anim==a2FRMSLOW)
13737 {
13738 tempguy.e_anim=a2FRM;
13739 tempguy.e_frate *= 2;
13740 }
13741
13742 if(tempguy.anim==aFLIPSLOW)
13743 {
13744 tempguy.anim=aFLIP;
13745 tempguy.frate *= 2;
13746 }
13747
13748 if(tempguy.e_anim==aFLIPSLOW)
13749 {
13750 tempguy.e_anim=aFLIP;
13751 tempguy.e_frate *= 2;
13752 }
13753
13754 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13755
13756 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13757
13758 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13759 {
13760 tempguy.anim=a4FRM4DIR;
13761 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13762 }
13763
13764 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13765 {
13766 tempguy.e_anim=a4FRM4DIR;
13767 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13768 }
13769 }
13770
13771
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.dp),f))
13772 {
13773 return qe_invalid;
13774 }
13775
13776 //correction for guy fire
13777
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 6)
13778 {
13779 if(i == gFIRE)
13780 tempguy.dp = 2;
13781 }
13782
13783
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.wdp),f))
13784 {
13785 return qe_invalid;
13786 }
13787
13788
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.weapon),f))
13789 {
13790 return qe_invalid;
13791 }
13792
13793 //correction for bosses using triple, "rising" fireballs
13794
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 5)
13795 {
13796 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13797 i == eGOHMA3 || i == eGOHMA4)
13798 {
13799 if(tempguy.weapon == ewFireball)
13800 tempguy.weapon = ewFireball2;
13801 }
13802 }
13803
13804
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.rate),f))
13805 {
13806 return qe_invalid;
13807 }
13808
13809
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.hrate),f))
13810 {
13811 return qe_invalid;
13812 }
13813
13814
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.step),f))
13815 {
13816 return qe_invalid;
13817 }
13818
13819 // HIGHLY UNORTHODOX UPDATING THING, part 2
13820
3/4
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 306688 times.
✓ Branch 2 taken 2560 times.
✗ Branch 3 not taken.
309248 if(fixpolsvoice && tempguy.family==eePOLSV)
13821 {
13822 tempguy.step /= 2;
13823 }
13824
13825
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.homing),f))
13826 {
13827 return qe_invalid;
13828 }
13829
13830
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.grumble),f))
13831 {
13832 return qe_invalid;
13833 }
13834
13835
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.item_set),f))
13836 {
13837 return qe_invalid;
13838 }
13839
13840
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13841 {
13842
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc1),f))
13843 {
13844 return qe_invalid;
13845 }
13846
13847
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc2),f))
13848 {
13849 return qe_invalid;
13850 }
13851
13852
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc3),f))
13853 {
13854 return qe_invalid;
13855 }
13856
13857
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc4),f))
13858 {
13859 return qe_invalid;
13860 }
13861
13862
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc5),f))
13863 {
13864 return qe_invalid;
13865 }
13866
13867
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc6),f))
13868 {
13869 return qe_invalid;
13870 }
13871
13872
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc7),f))
13873 {
13874 return qe_invalid;
13875 }
13876
13877
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc8),f))
13878 {
13879 return qe_invalid;
13880 }
13881
13882
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc9),f))
13883 {
13884 return qe_invalid;
13885 }
13886
13887
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc10),f))
13888 {
13889 return qe_invalid;
13890 }
13891 309248 }
13892 else
13893 {
13894 int16_t tempMisc;
13895
13896 if(!p_igetw(&tempMisc,f))
13897 {
13898 return qe_invalid;
13899 }
13900
13901 tempguy.misc1=tempMisc;
13902
13903 if(!p_igetw(&tempMisc,f))
13904 {
13905 return qe_invalid;
13906 }
13907
13908 tempguy.misc2=tempMisc;
13909
13910 if(!p_igetw(&tempMisc,f))
13911 {
13912 return qe_invalid;
13913 }
13914
13915 tempguy.misc3=tempMisc;
13916
13917 if(!p_igetw(&tempMisc,f))
13918 {
13919 return qe_invalid;
13920 }
13921
13922 tempguy.misc4=tempMisc;
13923
13924 if(!p_igetw(&tempMisc,f))
13925 {
13926 return qe_invalid;
13927 }
13928
13929 tempguy.misc5=tempMisc;
13930
13931 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13932 {
13933 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13934 tempguy.misc5 = 74;
13935 }
13936
13937 if(!p_igetw(&tempMisc,f))
13938 {
13939 return qe_invalid;
13940 }
13941
13942 tempguy.misc6=tempMisc;
13943
13944 if(!p_igetw(&tempMisc,f))
13945 {
13946 return qe_invalid;
13947 }
13948
13949 tempguy.misc7=tempMisc;
13950
13951 if(!p_igetw(&tempMisc,f))
13952 {
13953 return qe_invalid;
13954 }
13955
13956 tempguy.misc8=tempMisc;
13957
13958 if(!p_igetw(&tempMisc,f))
13959 {
13960 return qe_invalid;
13961 }
13962
13963 tempguy.misc9=tempMisc;
13964
13965 if(!p_igetw(&tempMisc,f))
13966 {
13967 return qe_invalid;
13968 }
13969
13970 tempguy.misc10=tempMisc;
13971 }
13972
13973
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.bgsfx),f))
13974 {
13975 return qe_invalid;
13976 }
13977
13978
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.bosspal),f))
13979 {
13980 return qe_invalid;
13981 }
13982
13983
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetw(&(tempguy.extend),f))
13984 {
13985 return qe_invalid;
13986 }
13987
13988 //! Enemy Defences
13989
13990 //If a 2.50 quest, use only the 2.5 defences.
13991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309248 times.
309248 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
13992 {
13993
2/2
✓ Branch 0 taken 5875712 times.
✓ Branch 1 taken 309248 times.
6184960 for(int32_t j=0; j<edefLAST; j++)
13994 {
13995
1/2
✓ Branch 0 taken 5875712 times.
✗ Branch 1 not taken.
5875712 if(!p_getc(&(tempguy.defense[j]),f))
13996 {
13997 return qe_invalid;
13998 }
13999 5875712 }
14000 //then copy the generic script defence to all the new script defences
14001
14002 309248 }
14003
14004
14005
14006
14007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309248 times.
309248 if(guyversion >= 18)
14008 {
14009
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.hitsfx),f))
14010 {
14011 return qe_invalid;
14012 }
14013
14014
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_getc(&(tempguy.deadsfx),f))
14015 {
14016 return qe_invalid;
14017 }
14018 309248 }
14019
14020
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion >= 22)
14021 {
14022
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc11),f))
14023 {
14024 return qe_invalid;
14025 }
14026
14027
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(!p_igetl(&(tempguy.misc12),f))
14028 {
14029 return qe_invalid;
14030 }
14031 309248 }
14032 else if(guyversion >= 19)
14033 {
14034 int16_t tempMisc;
14035
14036 if(!p_igetw(&tempMisc,f))
14037 {
14038 return qe_invalid;
14039 }
14040
14041 tempguy.misc11=tempMisc;
14042
14043 if(!p_igetw(&tempMisc,f))
14044 {
14045 return qe_invalid;
14046 }
14047
14048 tempguy.misc12=tempMisc;
14049 }
14050
14051 //If a 2.54 or later quest, use all of the defences.
14052
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion > 24) // Add new guyversion conditional statement
14053 {
14054
2/2
✓ Branch 0 taken 4719616 times.
✓ Branch 1 taken 214528 times.
4934144 for(int32_t j=edefLAST; j<edefLAST255; j++)
14055 {
14056
1/2
✓ Branch 0 taken 4719616 times.
✗ Branch 1 not taken.
4719616 if(!p_getc(&(tempguy.defense[j]),f))
14057 {
14058 return qe_invalid;
14059 }
14060 4719616 }
14061 214528 }
14062
14063
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14064 {
14065
2/2
✓ Branch 0 taken 947200 times.
✓ Branch 1 taken 94720 times.
1041920 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14066 {
14067 947200 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14068 947200 }
14069 94720 }
14070
14071 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14072
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion > 25)
14073 {
14074
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.txsz),f))
14075 {
14076 return qe_invalid;
14077 }
14078
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.tysz),f))
14079 {
14080 return qe_invalid;
14081 }
14082
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.hxsz),f))
14083 {
14084 return qe_invalid;
14085 }
14086
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.hysz),f))
14087 {
14088 return qe_invalid;
14089 }
14090
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.hzsz),f))
14091 {
14092 return qe_invalid;
14093 }
14094 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14095
14096 */
14097 214528 }
14098 //More Enemy Editor vars for 2.60
14099
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion > 26)
14100 {
14101
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.hxofs),f))
14102 {
14103 return qe_invalid;
14104 }
14105
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.hyofs),f))
14106 {
14107 return qe_invalid;
14108 }
14109
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.xofs),f))
14110 {
14111 return qe_invalid;
14112 }
14113
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.yofs),f))
14114 {
14115 return qe_invalid;
14116 }
14117
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.zofs),f))
14118 {
14119 return qe_invalid;
14120 }
14121 214528 }
14122
14123
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14124 {
14125 94720 tempguy.wpnsprite = 0;
14126 94720 }
14127
14128
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion > 27)
14129 {
14130
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.wpnsprite),f))
14131 {
14132 return qe_invalid;
14133 }
14134 214528 }
14135
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14136 {
14137 94720 tempguy.SIZEflags = 0;
14138 94720 }
14139
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion > 28)
14140 {
14141
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.SIZEflags),f))
14142 {
14143 return qe_invalid;
14144 }
14145
14146 214528 }
14147
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14148 {
14149 94720 tempguy.frozentile = 0;
14150 94720 tempguy.frozencset = 0;
14151 94720 tempguy.frozenclock = 0;
14152
2/2
✓ Branch 0 taken 947200 times.
✓ Branch 1 taken 94720 times.
1041920 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14153 94720 }
14154
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion >= 30)
14155 {
14156
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.frozentile),f))
14157 {
14158 return qe_invalid;
14159 }
14160
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.frozencset),f))
14161 {
14162 return qe_invalid;
14163 }
14164
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.frozenclock),f))
14165 {
14166 return qe_invalid;
14167 }
14168
2/2
✓ Branch 0 taken 2145280 times.
✓ Branch 1 taken 214528 times.
2359808 for ( int32_t q = 0; q < 10; q++ ) {
14169
1/2
✓ Branch 0 taken 2145280 times.
✗ Branch 1 not taken.
2145280 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14170 {
14171 return qe_invalid;
14172 }
14173 2145280 }
14174
14175 214528 }
14176
14177
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion >= 34)
14178 {
14179
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetw(&(tempguy.firesfx),f))
14180 {
14181 return qe_invalid;
14182 }
14183
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc16),f))
14184 {
14185 return qe_invalid;
14186 }
14187
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc17),f))
14188 {
14189 return qe_invalid;
14190 }
14191
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc18),f))
14192 {
14193 return qe_invalid;
14194 }
14195
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc19),f))
14196 {
14197 return qe_invalid;
14198 }
14199
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc20),f))
14200 {
14201 return qe_invalid;
14202 }
14203
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc21),f))
14204 {
14205 return qe_invalid;
14206 }
14207
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc22),f))
14208 {
14209 return qe_invalid;
14210 }
14211
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc23),f))
14212 {
14213 return qe_invalid;
14214 }
14215
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc24),f))
14216 {
14217 return qe_invalid;
14218 }
14219
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc25),f))
14220 {
14221 return qe_invalid;
14222 }
14223
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc26),f))
14224 {
14225 return qe_invalid;
14226 }
14227
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc27),f))
14228 {
14229 return qe_invalid;
14230 }
14231
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc28),f))
14232 {
14233 return qe_invalid;
14234 }
14235
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc29),f))
14236 {
14237 return qe_invalid;
14238 }
14239
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc30),f))
14240 {
14241 return qe_invalid;
14242 }
14243
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc31),f))
14244 {
14245 return qe_invalid;
14246 }
14247
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc32),f))
14248 {
14249 return qe_invalid;
14250 }
14251
14252
2/2
✓ Branch 0 taken 6864896 times.
✓ Branch 1 taken 214528 times.
7079424 for ( int32_t q = 0; q < 32; q++ ) {
14253
1/2
✓ Branch 0 taken 6864896 times.
✗ Branch 1 not taken.
6864896 if(!p_igetl(&(tempguy.movement[q]),f))
14254 {
14255 return qe_invalid;
14256 }
14257 6864896 }
14258
2/2
✓ Branch 0 taken 6864896 times.
✓ Branch 1 taken 214528 times.
7079424 for ( int32_t q = 0; q < 32; q++ ) {
14259
1/2
✓ Branch 0 taken 6864896 times.
✗ Branch 1 not taken.
6864896 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14260 {
14261 return qe_invalid;
14262 }
14263 6864896 }
14264
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetw(&(tempguy.script),f))
14265 {
14266 return qe_invalid;
14267 }
14268 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14269
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; q++ )
14270 {
14271
1/2
✓ Branch 0 taken 1716224 times.
✗ Branch 1 not taken.
1716224 if(!p_igetl(&(tempguy.initD[q]),f))
14272 {
14273 return qe_invalid;
14274 }
14275 1716224 }
14276
2/2
✓ Branch 0 taken 429056 times.
✓ Branch 1 taken 214528 times.
643584 for ( int32_t q = 0; q < 2; q++ )
14277 {
14278
1/2
✓ Branch 0 taken 429056 times.
✗ Branch 1 not taken.
429056 if(!p_igetl(&(tempguy.initA[q]),f))
14279 {
14280 return qe_invalid;
14281 }
14282 429056 }
14283
14284 214528 }
14285
14286
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion >= 37)
14287 {
14288
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.editorflags),f))
14289 {
14290 return qe_invalid;
14291 }
14292 214528 }
14293
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14294
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if(guyversion >= 38)
14295 {
14296
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc13),f))
14297 {
14298 return qe_invalid;
14299 }
14300
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc14),f))
14301 {
14302 return qe_invalid;
14303 }
14304
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetl(&(tempguy.misc15),f))
14305 {
14306 return qe_invalid;
14307 }
14308
14309 214528 }
14310
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion < 38 )
14311 {
14312 94720 tempguy.misc13 = 0;
14313 94720 tempguy.misc14 = 0;
14314 94720 tempguy.misc15 = 0;
14315 94720 }
14316
14317
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if ( guyversion >= 39 )
14318 {
14319
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; q++ )
14320 {
14321
2/2
✓ Branch 0 taken 111554560 times.
✓ Branch 1 taken 1716224 times.
113270784 for ( int32_t w = 0; w < 65; w++ )
14322 {
14323
1/2
✓ Branch 0 taken 111554560 times.
✗ Branch 1 not taken.
111554560 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14324 {
14325 return qe_invalid;
14326 }
14327 111554560 }
14328
2/2
✓ Branch 0 taken 111554560 times.
✓ Branch 1 taken 1716224 times.
113270784 for ( int32_t w = 0; w < 65; w++ )
14329 {
14330
1/2
✓ Branch 0 taken 111554560 times.
✗ Branch 1 not taken.
111554560 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14331 {
14332 return qe_invalid;
14333 }
14334 111554560 }
14335 1716224 }
14336
14337
14338 214528 }
14339
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion < 39 ) //apply old InitD strings to both
14340 {
14341
2/2
✓ Branch 0 taken 757760 times.
✓ Branch 1 taken 94720 times.
852480 for ( int32_t q = 0; q < 8; q++ )
14342 {
14343 757760 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14344 757760 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14345 757760 }
14346 94720 }
14347
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if ( guyversion >= 40 )
14348 {
14349
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_igetw(&(tempguy.weaponscript),f))
14350 {
14351 return qe_invalid;
14352 }
14353 214528 }
14354
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if ( guyversion < 40 )
14355 {
14356 94720 tempguy.weaponscript = 0;
14357 94720 }
14358 //eweapon script InitD
14359
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
309248 if ( guyversion >= 41 )
14360 {
14361
2/2
✓ Branch 0 taken 1716224 times.
✓ Branch 1 taken 214528 times.
1930752 for ( int32_t q = 0; q < 8; q++ )
14362 {
14363
1/2
✓ Branch 0 taken 1716224 times.
✗ Branch 1 not taken.
1716224 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14364 {
14365 return qe_invalid;
14366 }
14367 1716224 }
14368
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if ( guy_cversion < 4 )
14369 {
14370 if ( tempguy.family == eeKEESE )
14371 {
14372
14373 if ( !tempguy.misc1 )
14374 {
14375 tempguy.misc16 = 120;
14376 tempguy.misc17 = 16;
14377
14378 }
14379 }
14380 if ( tempguy.family == eePEAHAT )
14381 {
14382 tempguy.misc16 = 80;
14383 tempguy.misc17 = 16;
14384 }
14385
14386 if ( tempguy.family == eeGHINI )
14387 {
14388 tempguy.misc16 = 120;
14389 tempguy.misc17 = 10;
14390 }
14391
14392 }
14393 214528 }
14394
14395
14396
14397 //default weapon sprites (quest version < 2.54)
14398 //port over old defaults -Z
14399
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion < 32)
14400 {
14401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94720 times.
94720 if ( tempguy.wpnsprite <= 0 )
14402 {
14403
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80205 times.
✓ Branch 4 taken 750 times.
✓ Branch 5 taken 647 times.
✓ Branch 6 taken 1780 times.
✓ Branch 7 taken 1207 times.
✓ Branch 8 taken 2250 times.
✓ Branch 9 taken 191 times.
✓ Branch 10 taken 73 times.
✓ Branch 11 taken 419 times.
✓ Branch 12 taken 77 times.
✓ Branch 13 taken 849 times.
✓ Branch 14 taken 1675 times.
✓ Branch 15 taken 215 times.
✓ Branch 16 taken 299 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1435 times.
94720 switch(tempguy.weapon)
14404 {
14405 case wNone:
14406 80205 tempguy.wpnsprite = 0; break;
14407
14408 case wSword:
14409 case wBeam:
14410 case wBrang:
14411 case wBomb:
14412 case wSBomb:
14413 case wLitBomb:
14414 case wLitSBomb:
14415 case wArrow:
14416 case wFire:
14417 case wWhistle:
14418 case wBait:
14419 case wWand:
14420 case wMagic:
14421 case wCatching:
14422 case wWind:
14423 case wRefMagic:
14424 case wRefFireball:
14425 case wRefRock:
14426 case wHammer:
14427 case wHookshot:
14428 case wHSHandle:
14429 case wHSChain:
14430 case wSSparkle:
14431 case wFSparkle:
14432 case wSmack:
14433 case wPhantom:
14434 case wCByrna:
14435 case wRefBeam:
14436 case wStomp:
14437 case lwMax:
14438 case wScript1:
14439 case wScript2:
14440 case wScript3:
14441 case wScript4:
14442 case wScript5:
14443 case wScript6:
14444 case wScript7:
14445 case wScript8:
14446 case wScript9:
14447 case wScript10:
14448 case wIce:
14449 //Cannot use any of these weapons yet.
14450 tempguy.wpnsprite = -1;
14451 break;
14452
14453 case wEnemyWeapons:
14454 2648 case ewFireball: tempguy.wpnsprite = 17; break;
14455
14456 750 case ewArrow: tempguy.wpnsprite = 19; break;
14457 647 case ewBrang: tempguy.wpnsprite = 4; break;
14458 1780 case ewSword: tempguy.wpnsprite = 20; break;
14459 1207 case ewRock: tempguy.wpnsprite = 18; break;
14460 2250 case ewMagic: tempguy.wpnsprite = 21; break;
14461 191 case ewBomb: tempguy.wpnsprite = 78; break;
14462 73 case ewSBomb: tempguy.wpnsprite = 79; break;
14463 419 case ewLitBomb: tempguy.wpnsprite = 76; break;
14464 77 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14465 849 case ewFireTrail: tempguy.wpnsprite = 80; break;
14466 1675 case ewFlame: tempguy.wpnsprite = 35; break;
14467 215 case ewWind: tempguy.wpnsprite = 36; break;
14468 299 case ewFlame2: tempguy.wpnsprite = 81; break;
14469 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14470 case ewIce: tempguy.wpnsprite = 83; break;
14471 1435 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14472
14473
14474 default: break; //No assign.
14475 }
14476 94720 }
14477 94720 }
14478
14479 //default weapon fire sound (quest version < 2.54)
14480 //port over old defaults and zero new data. -Z
14481
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion < 34)
14482 {
14483
2/2
✓ Branch 0 taken 3031040 times.
✓ Branch 1 taken 94720 times.
3125760 for ( int32_t q = 0; q < 32; q++ )
14484 {
14485 3031040 tempguy.movement[q] = 0;
14486 3031040 tempguy.new_weapon[q] = 0;
14487
14488 3031040 }
14489
14490 //NPC Script attributes.
14491 94720 tempguy.script = 0; //No scripted enemies existed. -Z
14492
2/2
✓ Branch 0 taken 757760 times.
✓ Branch 1 taken 94720 times.
852480 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14493
2/2
✓ Branch 0 taken 189440 times.
✓ Branch 1 taken 94720 times.
284160 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14494
14495 94720 tempguy.misc16 = 0;
14496 94720 tempguy.misc17 = 0;
14497 94720 tempguy.misc18 = 0;
14498 94720 tempguy.misc19 = 0;
14499 94720 tempguy.misc20 = 0;
14500 94720 tempguy.misc21 = 0;
14501 94720 tempguy.misc22 = 0;
14502 94720 tempguy.misc23 = 0;
14503 94720 tempguy.misc24 = 0;
14504 94720 tempguy.misc25 = 0;
14505 94720 tempguy.misc26 = 0;
14506 94720 tempguy.misc27 = 0;
14507 94720 tempguy.misc28 = 0;
14508 94720 tempguy.misc29 = 0;
14509 94720 tempguy.misc30 = 0;
14510 94720 tempguy.misc31 = 0;
14511 94720 tempguy.misc32 = 0;
14512
14513 //old default sounds
14514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94720 times.
94720 if ( tempguy.firesfx <= 0 )
14515 {
14516
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80205 times.
✓ Branch 4 taken 750 times.
✓ Branch 5 taken 647 times.
✓ Branch 6 taken 1780 times.
✓ Branch 7 taken 1207 times.
✓ Branch 8 taken 2250 times.
✓ Branch 9 taken 191 times.
✓ Branch 10 taken 73 times.
✓ Branch 11 taken 419 times.
✓ Branch 12 taken 77 times.
✓ Branch 13 taken 849 times.
✓ Branch 14 taken 1675 times.
✓ Branch 15 taken 215 times.
✓ Branch 16 taken 299 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1435 times.
94720 switch(tempguy.weapon)
14517 {
14518 case wNone:
14519 80205 tempguy.firesfx = 0; break;
14520
14521 case wSword:
14522 case wBeam:
14523 case wBrang:
14524 case wBomb:
14525 case wSBomb:
14526 case wLitBomb:
14527 case wLitSBomb:
14528 case wArrow:
14529 case wFire:
14530 case wWhistle:
14531 case wBait:
14532 case wWand:
14533 case wMagic:
14534 case wCatching:
14535 case wWind:
14536 case wRefMagic:
14537 case wRefFireball:
14538 case wRefRock:
14539 case wHammer:
14540 case wHookshot:
14541 case wHSHandle:
14542 case wHSChain:
14543 case wSSparkle:
14544 case wFSparkle:
14545 case wSmack:
14546 case wPhantom:
14547 case wCByrna:
14548 case wRefBeam:
14549 case wStomp:
14550 case lwMax:
14551 case wScript1:
14552 case wScript2:
14553 case wScript3:
14554 case wScript4:
14555 case wScript5:
14556 case wScript6:
14557 case wScript7:
14558 case wScript8:
14559 case wScript9:
14560 case wScript10:
14561 case wIce:
14562 //Cannot use any of these weapons yet.
14563 tempguy.firesfx = -1;
14564 break;
14565
14566 case wEnemyWeapons:
14567 2648 case ewFireball: tempguy.firesfx = 40; break;
14568
14569 750 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14570 647 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14571 1780 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14572 1207 case ewRock: tempguy.firesfx = 51; break;
14573 2250 case ewMagic: tempguy.firesfx = 32; break;
14574 191 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14575 73 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14576 419 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14577 77 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14578 849 case ewFireTrail: tempguy.firesfx = 13; break;
14579 1675 case ewFlame: tempguy.firesfx = 13; break;
14580 215 case ewWind: tempguy.firesfx = 32; break;
14581 299 case ewFlame2: tempguy.firesfx = 13; break;
14582 case ewFlame2Trail: tempguy.firesfx = 13; break;
14583 case ewIce: tempguy.firesfx = 44; break;
14584 1435 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14585
14586 //what about special attacks (e.g. summoning == 56)
14587 default: break; //No assign.
14588 }
14589 94720 }
14590 94720 }
14591
14592 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14593
4/6
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
✓ Branch 2 taken 214528 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 214528 times.
309248 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14594 {
14595
2/2
✓ Branch 0 taken 11287 times.
✓ Branch 1 taken 83433 times.
94720 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14596 94720 }
14597 //Keese and bat halt rates.
14598
3/4
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 214528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94720 times.
309248 if ( guyversion < 42 && guy_cversion < 4 )
14599 {
14600
14601
2/2
✓ Branch 0 taken 93502 times.
✓ Branch 1 taken 1218 times.
94720 if ( tempguy.family == eeKEESE )
14602 {
14603
14604
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 873 times.
1218 if ( !tempguy.misc1 )
14605 {
14606 873 tempguy.misc16 = 120;
14607 873 tempguy.misc17 = 16;
14608
14609 873 }
14610 1218 }
14611
2/2
✓ Branch 0 taken 94285 times.
✓ Branch 1 taken 435 times.
94720 if ( tempguy.family == eePEAHAT )
14612 {
14613 435 tempguy.misc16 = 80;
14614 435 tempguy.misc17 = 16;
14615 435 }
14616
2/2
✓ Branch 0 taken 94535 times.
✓ Branch 1 taken 185 times.
94720 if ( tempguy.family == eeGHINI )
14617 {
14618 185 tempguy.misc16 = 120;
14619 185 tempguy.misc17 = 10;
14620 185 }
14621
14622
14623 94720 }
14624
14625
14626 //miscellaneous other corrections
14627 //fix the mirror wizzrobe -DD
14628
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 7)
14629 {
14630 if(i == eMWIZ)
14631 {
14632 tempguy.misc2 = 0;
14633 tempguy.misc4 = 1;
14634 }
14635 }
14636
14637
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 8)
14638 {
14639 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14640 {
14641 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14642 tempguy.misc5 = 4; //neck length in segments
14643 tempguy.misc6 = 8; //neck offset from first body tile
14644 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14645 tempguy.misc8 = 168; //head offset from first body tile
14646 tempguy.misc9 = 228; //flying head offset from first body tile
14647
14648 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14649 {
14650 tempguy.misc6 += 10; //neck offset from first body tile
14651 tempguy.misc8 -= 12; //head offset from first body tile
14652 }
14653 }
14654 }
14655
14656
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14657 {
14658 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14659 tempguy.bosspal = spDIG;
14660 }
14661
14662
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 11) // December 2007 - Spinning Tile fix
14663 {
14664 if(tempguy.family==eeSPINTILE)
14665 {
14666 tempguy.flags |= guy_superman;
14667 tempguy.item_set = 0; // Don't drop items
14668 tempguy.step = 300;
14669 }
14670 }
14671
14672
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14673 {
14674 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14675 {
14676 if(tempguy.family==eeROPE)
14677 {
14678 tempguy.flags2 &= ~guy_flashing;
14679 }
14680 }
14681
14682 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14683 {
14684 if(tempguy.family==eeBUBBLE)
14685 {
14686 tempguy.flags2 &= ~guy_flashing;
14687 }
14688 }
14689
14690 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14691 {
14692 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14693 {
14694 tempguy.flags2 |= guy_blinking;
14695 }
14696
14697 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14698 {
14699 tempguy.flags2 |= guy_transparent;
14700 }
14701 }
14702 }
14703
14704
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14705 {
14706 if(i==gFIRE)
14707 {
14708 tempguy.e_anim = aFLIP;
14709 tempguy.e_frate = 24;
14710 }
14711
14712 if(i==gFAIRY)
14713 {
14714 tempguy.e_anim = a2FRM;
14715 tempguy.e_frate = 16;
14716 }
14717 }
14718
14719
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14720 {
14721 if(i==0) Z_message("Updating guys to version 16...\n");
14722
14723 update_guy_1(&tempguy);
14724
14725 if(i==eMPOLSV)
14726 {
14727 tempguy.defense[edefARROW] = edCHINK;
14728 tempguy.defense[edefMAGIC] = ed1HKO;
14729 tempguy.defense[edefREFMAGIC] = ed1HKO;
14730 }
14731 }
14732
14733
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 17) // December 2009
14734 {
14735 if(tempguy.family==eePROJECTILE)
14736 {
14737 tempguy.misc1 = 0;
14738 }
14739 }
14740
14741
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 18) // January 2010
14742 {
14743 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14744 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14745
14746 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14747 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14748
14749 if(tempguy.family == eeAQUA)
14750 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14751 else if(tempguy.family == eeMANHAN)
14752 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14753 else if(tempguy.family==eePATRA)
14754 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14755 else if(tempguy.family==eeGHOMA)
14756 {
14757 for(int32_t j=0; j<edefLAST; j++)
14758 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14759
14760 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14761
14762 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14763
14764 tempguy.misc1--;
14765 }
14766 else if(tempguy.family == eeGLEEOK)
14767 {
14768 for(int32_t j=0; j<edefLAST; j++)
14769 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14770
14771 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14772 }
14773 else if(tempguy.family == eeARMOS)
14774 {
14775 tempguy.family=eeWALK;
14776 tempguy.hrate = 0;
14777 tempguy.misc10 = tempguy.misc1;
14778 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14779 tempguy.misc9 = e9tARMOS;
14780 }
14781 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14782 {
14783 tempguy.family=eeWALK;
14784 tempguy.hrate = 0;
14785 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14786 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14787 }
14788
14789 // Spawn animation flags
14790 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14791 tempguy.flags |= guy_fadeflicker;
14792 else
14793 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14794 }
14795
14796
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 20) // April 2010
14797 {
14798 if(tempguy.family == eeTRAP)
14799 {
14800 tempguy.misc2 = tempguy.misc10;
14801
14802 if(tempguy.misc10>=1)
14803 {
14804 tempguy.misc1++;
14805 }
14806
14807 tempguy.misc10 = 0;
14808 }
14809
14810 // Bomb Blast fix
14811 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14812 tempguy.weapon = ewLitBomb;
14813 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14814 tempguy.weapon = ewLitSBomb;
14815 }
14816
14817
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 21) // September 2011
14818 {
14819 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14820 {
14821 if(tempguy.family == eeKEESETRIB)
14822 {
14823 tempguy.family = eeKEESE;
14824 tempguy.misc2 = e2tKEESETRIB;
14825 tempguy.misc1 = 0;
14826 }
14827
14828 tempguy.rate = 2;
14829 tempguy.hrate = 8;
14830 tempguy.homing = 0;
14831 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14832 }
14833 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14834 {
14835 if(tempguy.family == eePEAHAT)
14836 {
14837 tempguy.rate = 4;
14838 tempguy.step = 62;
14839 }
14840 else
14841 tempguy.step = 25;
14842
14843 tempguy.hrate = 8;
14844 tempguy.homing = 0;
14845 }
14846 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14847 {
14848 if(tempguy.family == eeMANHAN)
14849 tempguy.step=50;
14850
14851 tempguy.hrate = 16;
14852 tempguy.homing = 0;
14853 }
14854 else if(tempguy.family == eeGLEEOK)
14855 {
14856 tempguy.rate = 2;
14857 tempguy.homing = 0;
14858 tempguy.hrate = 9;
14859 tempguy.step=89;
14860 }
14861 else if(tempguy.family == eeGHINI)
14862 {
14863 tempguy.rate = 4;
14864 tempguy.hrate = 12;
14865 tempguy.step=62;
14866 tempguy.homing = 0;
14867 }
14868
14869 // Bigdig random rate fix
14870 if(tempguy.family==eeDIG && tempguy.misc10==1)
14871 {
14872 tempguy.rate = 2;
14873 }
14874 }
14875
14876
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(guyversion < 24) // November 2012
14877 {
14878 if(tempguy.family==eeLANM)
14879 tempguy.misc3 = 1;
14880 else if(tempguy.family==eeMOLD)
14881 tempguy.misc2 = 0;
14882 }
14883
14884
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14885 {
14886
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 93405 times.
94720 if(tempguy.family!=eeDIG)
14887 {
14888 93405 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14889 93405 }
14890
14891 94720 }
14892 // does not seem to solve the issue!
14893
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if ( Header->zelda_version <= 0x210 )
14894 {
14895 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14896 if ( tempguy.family == eeDONGO )
14897 {
14898 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14899 }
14900 }
14901
14902
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion >= 42)
14903 {
14904
2/2
✓ Branch 0 taken 211968 times.
✓ Branch 1 taken 2560 times.
214528 if(guyversion >= 47)
14905 {
14906
1/2
✓ Branch 0 taken 211968 times.
✗ Branch 1 not taken.
211968 if(!p_igetl(&(tempguy.moveflags),f))
14907 {
14908 return qe_invalid;
14909 }
14910 211968 }
14911 else
14912 {
14913 byte fl;
14914
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14915 {
14916 return qe_invalid;
14917 }
14918 2560 tempguy.moveflags = fl;
14919 }
14920 214528 }
14921 else
14922 {
14923
7/8
✓ Branch 0 taken 2695 times.
✓ Branch 1 taken 74462 times.
✓ Branch 2 taken 2567 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 910 times.
✓ Branch 5 taken 599 times.
✓ Branch 6 taken 467 times.
✓ Branch 7 taken 13020 times.
94720 switch(tempguy.family)
14924 {
14925 //No gravity; floats over pits
14926 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14927 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14928 //Special (bosses, etc)
14929 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14930 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14931 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14932 74462 tempguy.moveflags = FLAG_CAN_PITWALK;
14933 74462 break;
14934 //No gravity, but falls in pits
14935 case eeLEV:
14936 910 tempguy.moveflags = FLAG_CAN_PITFALL;
14937 910 break;
14938 //Bosses that respect pits
14939 case eeDONGO:
14940 599 tempguy.moveflags = FLAG_OBEYS_GRAV;
14941 599 break;
14942 case eeLANM:
14943 467 tempguy.moveflags = 0;
14944 467 break;
14945 //Gravity, floats over pits
14946 case eeWIZZ: case eeWALLM: case eeGHINI:
14947 2567 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14948 2567 break;
14949 //Gravity and falls in pits
14950 case eeWALK:
14951
4/4
✓ Branch 0 taken 12369 times.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 500 times.
✓ Branch 3 taken 11869 times.
13020 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14952 1151 break;
14953 [[fallthrough]];
14954 case eeOTHER:
14955 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14956 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14957 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14958 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14959 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14960 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14961 14564 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14962 14564 }
14963 }
14964
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion < 43)
14965 {
14966
2/2
✓ Branch 0 taken 77029 times.
✓ Branch 1 taken 17691 times.
94720 switch(tempguy.family)
14967 {
14968 //No gravity; floats over pits
14969 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14970 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14971 //Special (bosses, etc)
14972 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14973 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14974 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14975 case eeWIZZ: case eeWALLM: case eeGHINI:
14976 //Gravity, floats over pits
14977 77029 tempguy.moveflags |= FLAG_CAN_WATERWALK;
14978 77029 tempguy.moveflags |= FLAG_CAN_PITWALK;
14979 77029 break;
14980 }
14981 94720 }
14982
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if (guyversion < 44)
14983 {
14984
2/2
✓ Branch 0 taken 93865 times.
✓ Branch 1 taken 855 times.
94720 if ( tempguy.family == eeGHOMA )
14985 {
14986 855 tempguy.flags |= guy_fadeinstant;
14987 855 }
14988 94720 }
14989
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if (guyversion > 44)
14990 {
14991
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_getc(&(tempguy.spr_shadow),f))
14992 {
14993 return qe_invalid;
14994 }
14995
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_getc(&(tempguy.spr_death),f))
14996 {
14997 return qe_invalid;
14998 }
14999
1/2
✓ Branch 0 taken 214528 times.
✗ Branch 1 not taken.
214528 if(!p_getc(&(tempguy.spr_spawn),f))
15000 {
15001 return qe_invalid;
15002 }
15003 214528 }
15004 else
15005 {
15006
2/2
✓ Branch 0 taken 94352 times.
✓ Branch 1 taken 368 times.
94720 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15007 94720 tempguy.spr_death = iwDeath;
15008 94720 tempguy.spr_spawn = iwSpawn;
15009 }
15010
15011
2/2
✓ Branch 0 taken 214528 times.
✓ Branch 1 taken 94720 times.
309248 if(guyversion < 46)
15012 {
15013
4/4
✓ Branch 0 taken 13020 times.
✓ Branch 1 taken 81700 times.
✓ Branch 2 taken 12369 times.
✓ Branch 3 taken 651 times.
94720 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15014 {
15015 651 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15016 651 }
15017 94720 }
15018
15019
1/2
✓ Branch 0 taken 309248 times.
✗ Branch 1 not taken.
309248 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15020 {
15021 tempguy.script = 0;
15022 for(int q = 0; q < 8; ++q)
15023 tempguy.initD[q] = 0;
15024 }
15025 309248 guysbuf[i] = tempguy;
15026 309248 }
15027 604 }
15028
15029 604 return 0;
15030 686 }
15031
15032 void update_guy_1(guydata *tempguy) // November 2009
15033 {
15034 bool doesntcount = false;
15035 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15036
15037 switch(tempguy->family)
15038 {
15039 case 1: //eeWALK
15040 switch(tempguy->misc10)
15041 {
15042 case 0: //Stalfos
15043 if(tempguy->misc1==1) // Fires four projectiles at once
15044 tempguy->misc1=4;
15045
15046 break;
15047
15048 case 1: //Darknut
15049 goto darknuts;
15050 break;
15051 }
15052
15053 tempguy->misc10 = 0;
15054 break;
15055
15056 case 2: //eeSHOOT
15057 tempguy->family = eeWALK;
15058
15059 switch(tempguy->misc10)
15060 {
15061 case 0: //Octorok
15062 if(tempguy->misc1==1||tempguy->misc1==2)
15063 {
15064 tempguy->misc1=e1tFIREOCTO;
15065 tempguy->misc2=e2tFIREOCTO;
15066 }
15067 else tempguy->misc1 = 0;
15068
15069 tempguy->misc6=tempguy->misc4;
15070 tempguy->misc4=tempguy->misc3;
15071 tempguy->misc3=0;
15072 break;
15073
15074 case 1: // Moblin
15075 tempguy->misc1 = 0;
15076 break;
15077
15078 case 2: //Lynel
15079 tempguy->misc6=tempguy->misc1+1;
15080 tempguy->misc1=0;
15081 break;
15082
15083 case 3: //Stalfos 2
15084 if(tempguy->misc1==1) // Fires four projectiles at once
15085 tempguy->misc1=e1t4SHOTS;
15086 else tempguy->misc1 = 0;
15087
15088 break;
15089
15090 case 4: //Darknut 5
15091 darknuts:
15092 tempguy->defense[edefFIRE] = edIGNORE;
15093 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15094 tempguy->defense[edefHOOKSHOT] = 0;
15095 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15096 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15097
15098 if(tempguy->misc1==1)
15099 tempguy->misc1=2;
15100 else if(tempguy->misc1==2)
15101 {
15102 tempguy->misc4=tempguy->misc3;
15103 tempguy->misc3=tempguy->misc2;
15104 tempguy->misc2=e2tSPLIT;
15105 tempguy->misc1 = 0;
15106 }
15107 else tempguy->misc1 = 0;
15108
15109 tempguy->flags |= inv_front;
15110
15111 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15112 tempguy->flags |= guy_bkshield;
15113
15114 break;
15115 }
15116
15117 tempguy->misc10 = 0;
15118 break;
15119
15120 /*
15121 case 9: //eeARMOS
15122 tempguy->family = eeWALK;
15123 break;
15124 */
15125 case 11: //eeGEL
15126 case 33: //eeGELTRIB
15127 if(tempguy->family==33)
15128 {
15129 tempguy->misc4 = 1;
15130
15131 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15132 tempguy->misc3 = tempguy->misc2;
15133
15134 tempguy->misc2 = e2tTRIBBLE;
15135 }
15136 else
15137 {
15138 tempguy->misc4 = 0;
15139 tempguy->misc3 = 0;
15140 tempguy->misc2 = 0;
15141 }
15142
15143 tempguy->family = eeWALK;
15144
15145 if(tempguy->misc1)
15146 {
15147 tempguy->misc1=1;
15148 tempguy->weapon = ewFireTrail;
15149 }
15150
15151 break;
15152
15153 case 34: //eeZOLTRIB
15154 case 12: //eeZOL
15155 tempguy->misc4=tempguy->misc3;
15156 tempguy->misc3=tempguy->misc2;
15157 tempguy->family = eeWALK;
15158 tempguy->misc2=e2tSPLITHIT;
15159
15160 if(tempguy->misc1)
15161 {
15162 tempguy->misc1=1;
15163 tempguy->weapon = ewFireTrail;
15164 }
15165
15166 break;
15167
15168 case 13: //eeROPE
15169 tempguy->family = eeWALK;
15170 tempguy->misc9 = e9tROPE;
15171
15172 if(tempguy->misc1)
15173 {
15174 tempguy->misc4 = tempguy->misc3;
15175 tempguy->misc3 = tempguy->misc2;
15176 tempguy->misc2 = e2tBOMBCHU;
15177 }
15178
15179 tempguy->misc1 = 0;
15180 break;
15181
15182 case 14: //eeGORIYA
15183 tempguy->family = eeWALK;
15184
15185 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15186
15187 break;
15188
15189 case 17: //eeBUBBLE
15190 tempguy->family = eeWALK;
15191 tempguy->misc8 = tempguy->misc2;
15192 tempguy->misc7 = tempguy->misc1 + 1;
15193 tempguy->misc1 = tempguy->misc2 = 0;
15194
15195 //fallthrogh
15196 case eeTRAP:
15197 case eeROCK:
15198 doesntcount = true;
15199 break;
15200
15201 case 35: //eeVIRETRIB
15202 case 18: //eeVIRE
15203 tempguy->family = eeWALK;
15204 tempguy->misc4=tempguy->misc3;
15205 tempguy->misc3=tempguy->misc2;
15206 tempguy->misc2=e2tSPLITHIT;
15207 tempguy->misc9=e9tVIRE;
15208 break;
15209
15210 case 19: //eeLIKE
15211 tempguy->family = eeWALK;
15212 tempguy->misc7 = e7tEATITEMS;
15213 tempguy->misc8=95;
15214 break;
15215
15216 case 20: //eePOLSV
15217 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15218 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15219 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15220 tempguy->defense[edefARROW] = ed1HKO;
15221 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15222 tempguy->family = eeWALK;
15223 tempguy->misc9 = e9tPOLSVOICE;
15224 tempguy->rate = 4;
15225 tempguy->homing = 32;
15226 tempguy->hrate = 10;
15227 tempguy->grumble = 0;
15228 break;
15229
15230 case eeWIZZ:
15231 if(tempguy->misc4)
15232 {
15233 for(int32_t i=0; i < edefLAST; i++)
15234 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15235 }
15236 else
15237 {
15238 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15239 tempguy->defense[edefMAGIC] = edCHINK;
15240 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15241 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15242 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15243 }
15244
15245 break;
15246
15247 case eePEAHAT:
15248 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15249
15250 if(!(tempguy->flags & guy_bhit))
15251 tempguy->defense[edefBRANG] = edSTUNONLY;
15252
15253 break;
15254
15255 case eeLEV:
15256 tempguy->defense[edefSTOMP] = edCHINK;
15257 break;
15258 }
15259
15260 // Old flags
15261 if(tempguy->flags & guy_superman)
15262 {
15263 for(int32_t i = 0; i < edefLAST; i++)
15264 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15265 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15266 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15267 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15268 }
15269
15270 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15271
15272 if(doesntcount)
15273 tempguy->flags |= (guy_doesntcount);
15274 }
15275
15276
15277 1153832 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15278 {
15279 byte tempbyte, padding;
15280 int32_t extras, secretcombos;
15281 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->valid),f))
15283 {
15284 return qe_invalid;
15285 }
15286
15287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->guy),f))
15288 return qe_invalid;
15289 1153832 temp_mapscr->guytile = -1; //signal to use default guy values
15290
2/2
✓ Branch 0 taken 1153255 times.
✓ Branch 1 taken 577 times.
1153832 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15291
4/4
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1153255 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 535 times.
1153832 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15292
15293
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15294 {
15295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15296 {
15297 return qe_invalid;
15298 }
15299
15300 22176 temp_mapscr->str=tempbyte;
15301 22176 }
15302 else
15303 {
15304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1131656 times.
1131656 if(!p_igetw(&(temp_mapscr->str),f))
15305 {
15306 return qe_invalid;
15307 }
15308 }
15309
15310
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->room),f))
15311 {
15312 return qe_invalid;
15313 }
15314
15315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->item),f))
15316 {
15317 return qe_invalid;
15318 }
15319
15320
3/6
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 625328 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15321 {
15322 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15323 528504 }
15324 else
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->hasitem),f))
15327 return qe_invalid;
15328 }
15329
15330
3/4
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156552 if((Header->zelda_version < 0x192)||
15331
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
1131656 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15332 {
15333
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15334 {
15335 return qe_invalid;
15336 }
15337 22176 }
15338
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15340 {
15341 return qe_invalid;
15342 }
15343
15344
2/2
✓ Branch 0 taken 1128936 times.
✓ Branch 1 taken 24896 times.
1153832 if(Header->zelda_version < 0x193)
15345 {
15346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15347 {
15348 return qe_invalid;
15349 }
15350 24896 }
15351
15352
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15353 {
15354
2/2
✓ Branch 0 taken 1875984 times.
✓ Branch 1 taken 625328 times.
2501312 for(int32_t i=1; i<4; i++)
15355 {
15356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875984 times.
1875984 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15357 {
15358 return qe_invalid;
15359 }
15360 1875984 }
15361 625328 }
15362 else
15363 {
15364 528504 temp_mapscr->tilewarptype[1]=0;
15365 528504 temp_mapscr->tilewarptype[2]=0;
15366 528504 temp_mapscr->tilewarptype[3]=0;
15367 }
15368
15369
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15370 {
15371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1131656 times.
1131656 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15372 {
15373 return qe_invalid;
15374 }
15375 1131656 }
15376
15377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15378 {
15379 return qe_invalid;
15380 }
15381
15382 1153832 temp_mapscr->warpreturnx[1]=0;
15383 1153832 temp_mapscr->warpreturnx[2]=0;
15384 1153832 temp_mapscr->warpreturnx[3]=0;
15385
15386
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15387 {
15388
2/2
✓ Branch 0 taken 1875984 times.
✓ Branch 1 taken 625328 times.
2501312 for(int32_t i=1; i<4; i++)
15389 {
15390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875984 times.
1875984 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15391 {
15392 return qe_invalid;
15393 }
15394 1875984 }
15395 625328 }
15396
15397
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15398 {
15399 return qe_invalid;
15400 }
15401
15402 1153832 temp_mapscr->warpreturny[1]=0;
15403 1153832 temp_mapscr->warpreturny[2]=0;
15404 1153832 temp_mapscr->warpreturny[3]=0;
15405
15406
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15407 {
15408
2/2
✓ Branch 0 taken 1875984 times.
✓ Branch 1 taken 625328 times.
2501312 for(int32_t i=1; i<4; i++)
15409 {
15410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875984 times.
1875984 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15411 {
15412 return qe_invalid;
15413 }
15414 1875984 }
15415
15416
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(version>=18)
15417 {
15418
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15419 {
15420 return qe_invalid;
15421 }
15422 625328 }
15423 else
15424 {
15425 byte temp;
15426
15427 if(!p_getc(&temp,f))
15428 {
15429 return qe_invalid;
15430 }
15431
15432 temp_mapscr->warpreturnc=temp<<8|temp;
15433 }
15434 625328 }
15435
15436
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->stairx),f))
15437
15438 {
15439 return qe_invalid;
15440 }
15441
15442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->stairy),f))
15443 {
15444 return qe_invalid;
15445 }
15446
15447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->itemx),f))
15448 {
15449 return qe_invalid;
15450 }
15451
15452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->itemy),f))
15453 {
15454 return qe_invalid;
15455 }
15456
15457
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version > 15) // February 2009
15458 {
15459
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_igetw(&(temp_mapscr->color),f))
15460 {
15461 return qe_invalid;
15462 }
15463 625328 }
15464 else
15465 {
15466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15467 {
15468 return qe_invalid;
15469 }
15470
15471 528504 temp_mapscr->color = (word) tempbyte;
15472 }
15473
15474
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->enemyflags),f))
15475 {
15476 return qe_invalid;
15477 }
15478
15479
2/2
✓ Branch 0 taken 4615328 times.
✓ Branch 1 taken 1153832 times.
5769160 for(int32_t k=0; k<4; k++)
15480 {
15481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4615328 times.
4615328 if(!p_getc(&(temp_mapscr->door[k]),f))
15482 {
15483 return qe_invalid;
15484
15485 }
15486 4615328 }
15487
15488
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
1153832 if(version <= 11)
15489 {
15490
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15491 {
15492 return qe_invalid;
15493 }
15494
15495 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15496
15497
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15498 {
15499 for(int32_t i=1; i<4; i++)
15500 {
15501 if(!p_getc(&(tempbyte),f))
15502 {
15503 return qe_invalid;
15504 }
15505
15506 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15507 }
15508 }
15509 else
15510 {
15511 528504 temp_mapscr->tilewarpdmap[1]=0;
15512 528504 temp_mapscr->tilewarpdmap[2]=0;
15513 528504 temp_mapscr->tilewarpdmap[3]=0;
15514 }
15515 528504 }
15516 else
15517 {
15518
2/2
✓ Branch 0 taken 2501312 times.
✓ Branch 1 taken 625328 times.
3126640 for(int32_t i=0; i<4; i++)
15519 {
15520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2501312 times.
2501312 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15521 {
15522 return qe_invalid;
15523 }
15524 2501312 }
15525 }
15526
15527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15528 {
15529 return qe_invalid;
15530 }
15531
15532
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15533 {
15534
2/2
✓ Branch 0 taken 1875984 times.
✓ Branch 1 taken 625328 times.
2501312 for(int32_t i=1; i<4; i++)
15535 {
15536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875984 times.
1875984 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15537 {
15538 return qe_invalid;
15539 }
15540 1875984 }
15541 625328 }
15542 else
15543 {
15544 528504 temp_mapscr->tilewarpscr[1]=0;
15545 528504 temp_mapscr->tilewarpscr[2]=0;
15546 528504 temp_mapscr->tilewarpscr[3]=0;
15547 }
15548
15549
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version >= 15)
15550 {
15551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15552 {
15553 return qe_invalid;
15554 }
15555 625328 }
15556 else
15557 {
15558 528504 temp_mapscr->tilewarpoverlayflags=0;
15559 }
15560
15561
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->exitdir),f))
15562 {
15563 return qe_invalid;
15564 }
15565
15566
2/2
✓ Branch 0 taken 1128936 times.
✓ Branch 1 taken 24896 times.
1153832 if(Header->zelda_version < 0x193)
15567 {
15568
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15569 {
15570 return qe_invalid;
15571 }
15572
15573 24896 }
15574
15575
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1151112 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15576 {
15577 if(!p_getc(&padding,f))
15578 {
15579 return qe_invalid;
15580 }
15581 }
15582
15583
2/2
✓ Branch 0 taken 11538320 times.
✓ Branch 1 taken 1153832 times.
12692152 for(int32_t k=0; k<10; k++)
15584 {
15585 /*
15586 if (!temp_mapscr->enemy[k])
15587 {
15588 continue;
15589 }
15590 */
15591
5/6
✓ Branch 0 taken 11316560 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11289360 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11538320 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15592 {
15593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15594 {
15595 return qe_invalid;
15596 }
15597
15598 221760 temp_mapscr->enemy[k]=tempbyte;
15599 221760 }
15600 else
15601 {
15602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11316560 times.
11316560 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15603 {
15604 return qe_invalid;
15605 }
15606 }
15607
15608
5/6
✓ Branch 0 taken 11316560 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11289360 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11538320 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15609 {
15610 //using enumerations here is dangerous
15611 //very easy to break old quests -DD
15612
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15613 {
15614 1342 temp_mapscr->enemy[k]+=5;
15615 1342 }
15616
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15617 {
15618 94 temp_mapscr->enemy[k]+=1;
15619 94 }
15620 221760 }
15621
15622
2/2
✓ Branch 0 taken 6253280 times.
✓ Branch 1 taken 5285040 times.
11538320 if(version < 9)
15623 {
15624
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15625 {
15626 275905 temp_mapscr->enemy[k]+=10;
15627 275905 }
15628 5285040 }
15629 //don't read in any invalid data
15630
2/2
✓ Branch 0 taken 11537870 times.
✓ Branch 1 taken 450 times.
11538320 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15631 {
15632 450 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15633 450 temp_mapscr->enemy[k] = 0;
15634 450 }
15635 11538320 }
15636
15637
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->pattern),f))
15638 {
15639 return qe_invalid;
15640 }
15641
15642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15643 {
15644 return qe_invalid;
15645 }
15646
15647
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15648 {
15649
2/2
✓ Branch 0 taken 1875984 times.
✓ Branch 1 taken 625328 times.
2501312 for(int32_t i=1; i<4; i++)
15650 {
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875984 times.
1875984 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15652 {
15653 return qe_invalid;
15654 }
15655 1875984 }
15656 625328 }
15657 else
15658 {
15659 528504 temp_mapscr->sidewarptype[1]=0;
15660 528504 temp_mapscr->sidewarptype[2]=0;
15661 528504 temp_mapscr->sidewarptype[3]=0;
15662 }
15663
15664
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version >= 15)
15665 {
15666
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15667 {
15668 return qe_invalid;
15669 }
15670 625328 }
15671 else
15672 {
15673 528504 temp_mapscr->sidewarpoverlayflags=0;
15674 }
15675
15676
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15677 {
15678 return qe_invalid;
15679 }
15680
15681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15682 {
15683 return qe_invalid;
15684 }
15685
15686
2/2
✓ Branch 0 taken 4615328 times.
✓ Branch 1 taken 1153832 times.
5769160 for(int32_t k=0; k<4; k++)
15687 {
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4615328 times.
4615328 if(!p_getc(&(temp_mapscr->path[k]),f))
15689 {
15690 return qe_invalid;
15691 }
15692 4615328 }
15693
15694
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15695 {
15696 return qe_invalid;
15697 }
15698
15699
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15700 {
15701
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 1875984 times.
2501312 for(int32_t i=1; i<4; i++)
15702 {
15703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875984 times.
1875984 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15704 {
15705 return qe_invalid;
15706 }
15707 1875984 }
15708 625328 }
15709 else
15710 {
15711 528504 temp_mapscr->sidewarpscr[1]=0;
15712 528504 temp_mapscr->sidewarpscr[2]=0;
15713 528504 temp_mapscr->sidewarpscr[3]=0;
15714 }
15715
15716
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
1153832 if(version <= 11)
15717 {
15718
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15719 {
15720 return qe_invalid;
15721 }
15722
15723 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15724
15725
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15726 {
15727 for(int32_t i=1; i<4; i++)
15728 {
15729 if(!p_getc(&(tempbyte),f))
15730 {
15731 return qe_invalid;
15732 }
15733
15734 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15735 }
15736 }
15737 else
15738 {
15739 528504 temp_mapscr->sidewarpdmap[1]=0;
15740 528504 temp_mapscr->sidewarpdmap[2]=0;
15741 528504 temp_mapscr->sidewarpdmap[3]=0;
15742 }
15743 528504 }
15744 else
15745 {
15746
2/2
✓ Branch 0 taken 2501312 times.
✓ Branch 1 taken 625328 times.
3126640 for(int32_t i=0; i<4; i++)
15747 {
15748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2501312 times.
2501312 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15749 {
15750 return qe_invalid;
15751 }
15752 2501312 }
15753 }
15754
15755
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15756 {
15757
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15758 {
15759 return qe_invalid;
15760 }
15761 625328 }
15762 528504 else temp_mapscr->sidewarpindex = 0;
15763
15764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_igetw(&(temp_mapscr->undercombo),f))
15765 {
15766 return qe_invalid;
15767 }
15768
15769
2/2
✓ Branch 0 taken 1128936 times.
✓ Branch 1 taken 24896 times.
1153832 if(Header->zelda_version < 0x193)
15770 {
15771
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&(temp_mapscr->old_cpage),f))
15772 {
15773 return qe_invalid;
15774 }
15775 24896 }
15776
15777
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15778 {
15779 return qe_invalid;
15780 }
15781
15782
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_igetw(&(temp_mapscr->catchall),f))
15783 {
15784 return qe_invalid;
15785 }
15786
15787
1/2
✓ Branch 0 taken 1153832 times.
✗ Branch 1 not taken.
1153832 if(!p_getc(&(temp_mapscr->flags),f))
15788 {
15789 return qe_invalid;
15790 }
15791
15792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->flags2),f))
15793 {
15794 return qe_invalid;
15795 }
15796
15797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(!p_getc(&(temp_mapscr->flags3),f))
15798 {
15799 return qe_invalid;
15800 }
15801
15802
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15803 //if (version>2)
15804 {
15805
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->flags4),f))
15806 {
15807 return qe_invalid;
15808 }
15809 625328 }
15810
15811
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15812 {
15813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->flags5),f))
15814 {
15815 return qe_invalid;
15816 }
15817
15818
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_igetw(&(temp_mapscr->noreset),f))
15819 {
15820 return qe_invalid;
15821 }
15822
15823
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_igetw(&(temp_mapscr->nocarry),f))
15824 {
15825 return qe_invalid;
15826 }
15827
15828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(temp_mapscr->flags5&32)
15829 {
15830 temp_mapscr->flags5 &= ~32;
15831 temp_mapscr->noreset |= 48;
15832 }
15833
15834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(version<8)
15835 {
15836 if(temp_mapscr->noreset&1)
15837 {
15838 temp_mapscr->noreset|=8192;
15839 }
15840
15841 if(temp_mapscr->nocarry&1)
15842 {
15843 temp_mapscr->nocarry|=8192;
15844 temp_mapscr->nocarry&=~1;
15845 }
15846 }
15847 625328 }
15848 else
15849 {
15850 528504 temp_mapscr->flags5 = 0;
15851 528504 temp_mapscr->noreset = 0;
15852 528504 temp_mapscr->nocarry = 0;
15853 }
15854
15855
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15856 {
15857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->flags6),f))
15858 {
15859 return qe_invalid;
15860 }
15861 625328 }
15862
15863
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version>5)
15864 {
15865
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->flags7),f))
15866 {
15867 return qe_invalid;
15868 }
15869
15870
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->flags8),f))
15871 {
15872 return qe_invalid;
15873 }
15874
15875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->flags9),f))
15876 {
15877 return qe_invalid;
15878 }
15879
15880
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->flags10),f))
15881 {
15882 return qe_invalid;
15883 }
15884
15885
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->csensitive),f))
15886 {
15887 return qe_invalid;
15888 }
15889 625328 }
15890 else
15891 {
15892 528504 temp_mapscr->csensitive=1;
15893 }
15894
15895
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
1153832 if(version<14) // August 2007: screen SFX added
15896 {
15897
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
15898 {
15899 994 temp_mapscr->bosssfx=
15900
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15901 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15902 WAV_ROAR;
15903 994 }
15904
15905
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA
15906 {
15907 170 temp_mapscr->oceansfx=WAV_SEA;
15908 170 }
15909
15910 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15911 ? 0 : WAV_SECRET;
15912
15913 528504 temp_mapscr->flags3 &= ~66; //64|2
15914 528504 temp_mapscr->flags2 &= ~32;
15915 528504 temp_mapscr->flags &= ~136; // 128|8
15916 528504 }
15917 else
15918 {
15919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->oceansfx),f))
15920 {
15921 return qe_invalid;
15922 }
15923
15924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->bosssfx),f))
15925 {
15926 return qe_invalid;
15927 }
15928
15929
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->secretsfx),f))
15930 {
15931 return qe_invalid;
15932 }
15933 }
15934
15935
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
1153832 if(version<15) // October 2007: another SFX
15936 {
15937 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
15938 528504 }
15939 else
15940 {
15941
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15942 {
15943 return qe_invalid;
15944 }
15945 }
15946
15947
15948
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15949 {
15950
2/2
✓ Branch 0 taken 6789936 times.
✓ Branch 1 taken 1131656 times.
7921592 for(int32_t k=0; k<6; k++)
15951 {
15952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6789936 times.
6789936 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15953 {
15954 return qe_invalid;
15955 }
15956 6789936 }
15957
15958
2/2
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 6789936 times.
7921592 for(int32_t k=0; k<6; k++)
15959 {
15960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6789936 times.
6789936 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15961 {
15962 return qe_invalid;
15963 }
15964 6789936 }
15965 1131656 }
15966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15967 {
15968 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15969 {
15970 return qe_invalid;
15971 }
15972
15973 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15974 {
15975 return qe_invalid;
15976 }
15977
15978 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15979 {
15980 return qe_invalid;
15981 }
15982
15983 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
15984
15985 {
15986 return qe_invalid;
15987 }
15988 }
15989
15990
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1151112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1153832 if((Header->zelda_version == 0x192)&&(Header->build>149))
15991 {
15992
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15993 {
15994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
15995 {
15996 return qe_invalid;
15997 }
15998 16320 }
15999
16000
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16001 {
16002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16003 {
16004 return qe_invalid;
16005 }
16006 16320 }
16007
16008
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16009 {
16010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16011 {
16012 return qe_invalid;
16013 }
16014 16320 }
16015
16016
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16017 {
16018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16019 {
16020 return qe_invalid;
16021 }
16022 16320 }
16023
16024
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16025 {
16026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16027 {
16028 return qe_invalid;
16029 }
16030 16320 }
16031
16032
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16033 {
16034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16035 {
16036 return qe_invalid;
16037 }
16038 16320 }
16039 2720 }
16040
16041
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16042 {
16043
2/2
✓ Branch 0 taken 6789936 times.
✓ Branch 1 taken 1131656 times.
7921592 for(int32_t k=0; k<6; k++)
16044 {
16045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6789936 times.
6789936 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16046 {
16047 return qe_invalid;
16048 }
16049 6789936 }
16050 1131656 }
16051
16052
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16053 {
16054
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1131656 if((Header->zelda_version == 0x192)&&(Header->build>153))
16055 {
16056
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16057 {
16058 return qe_invalid;
16059 }
16060 2720 }
16061
16062
1/2
✓ Branch 0 taken 1131656 times.
✗ Branch 1 not taken.
1131656 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16063 {
16064 return qe_invalid;
16065 }
16066 1131656 }
16067
16068
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16069 {
16070 22176 extras=15;
16071 22176 }
16072
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1131656 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16073 {
16074 extras=11;
16075 }
16076
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1131656 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16077 {
16078 extras=32;
16079 }
16080
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1131656 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16081 {
16082 extras=64;
16083 }
16084
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
1131656 else if(Header->zelda_version < 0x193)
16085 {
16086 2720 extras=62;
16087 2720 }
16088 else
16089
16090 {
16091 1128936 extras=0;
16092 }
16093
16094
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1153832 times.
1655112 for(int32_t k=0; k<extras; k++)
16095 {
16096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16097 {
16098 return qe_invalid;
16099 }
16100 501280 }
16101
16102
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16103 //if (version>3)
16104 {
16105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_getc(&(temp_mapscr->nextmap),f))
16106 {
16107 return qe_invalid;
16108 }
16109
16110
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->nextscr),f))
16111 {
16112 return qe_invalid;
16113 }
16114 625328 }
16115 else
16116 {
16117 528504 temp_mapscr->nextmap=0;
16118 528504 temp_mapscr->nextscr=0;
16119 }
16120
16121
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16122 {
16123 22176 secretcombos=20;
16124 22176 }
16125
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1128936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1131656 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16126 {
16127 secretcombos=256;
16128 }
16129 else
16130 {
16131 1131656 secretcombos=128;
16132 }
16133
16134
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16135 {
16136
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16137 {
16138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16139 {
16140 return qe_invalid;
16141 }
16142
16143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16144 {
16145 443520 temp_mapscr->secretcombo[k]=tempbyte;
16146 443520 }
16147 443520 }
16148 22176 }
16149 else
16150 {
16151
2/2
✓ Branch 0 taken 144851968 times.
✓ Branch 1 taken 1131656 times.
145983624 for(int32_t k=0; k<128; k++)
16152 {
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144851968 times.
144851968 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16154 {
16155 return qe_invalid;
16156 }
16157
16158 144851968 }
16159 }
16160
16161
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16162 {
16163
2/2
✓ Branch 0 taken 144851968 times.
✓ Branch 1 taken 1131656 times.
145983624 for(int32_t k=0; k<128; k++)
16164 {
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144851968 times.
144851968 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16166 {
16167 return qe_invalid;
16168 }
16169 144851968 }
16170
16171
2/2
✓ Branch 0 taken 144851968 times.
✓ Branch 1 taken 1131656 times.
145983624 for(int32_t k=0; k<128; k++)
16172 {
16173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144851968 times.
144851968 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16174 {
16175 return qe_invalid;
16176 }
16177 144851968 }
16178 1131656 }
16179
16180
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1151112 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16181 {
16182 if(!p_getc(&padding,f))
16183 {
16184 return qe_invalid;
16185 }
16186 }
16187
16188
2/2
✓ Branch 0 taken 203074432 times.
✓ Branch 1 taken 1153832 times.
204228264 for(int32_t k=0; k<176; k++)
16189 {
16190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203074432 times.
203074432 if(!p_igetw(&(temp_mapscr->data[k]),f))
16191 {
16192 return qe_invalid;
16193 }
16194 203074432 }
16195
16196
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1151112 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16197 {
16198 if(!p_getc(&padding,f))
16199 {
16200 return qe_invalid;
16201 }
16202
16203 if(!p_getc(&padding,f))
16204 {
16205 return qe_invalid;
16206 }
16207 }
16208
16209
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16210 {
16211
2/2
✓ Branch 0 taken 199171456 times.
✓ Branch 1 taken 1131656 times.
200303112 for(int32_t k=0; k<176; k++)
16212 {
16213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199171456 times.
199171456 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16214 {
16215 return qe_invalid;
16216 }
16217
16218
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 198692736 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
199171456 if((Header->zelda_version == 0x192)&&(Header->build<24))
16219 {
16220 if(!p_getc(&tempbyte,f))
16221 {
16222 return qe_invalid;
16223 }
16224
16225 if(!p_getc(&tempbyte,f))
16226 {
16227 return qe_invalid;
16228 }
16229
16230 if(!p_getc(&tempbyte,f))
16231 {
16232 return qe_invalid;
16233 }
16234 }
16235 199171456 }
16236 1131656 }
16237
16238
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1128936 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1153832 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16239 {
16240
2/2
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 199171456 times.
200303112 for(int32_t k=0; k<176; k++)
16241 {
16242
16243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199171456 times.
199171456 if(!p_getc(&(temp_mapscr->cset[k]),f))
16244 {
16245 return qe_invalid;
16246 }
16247 199171456 }
16248 1131656 }
16249
16250
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16251 {
16252 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16253 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16254 22176 }
16255
16256
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16257 {
16258 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16259 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16260 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16261 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16262 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16263 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16264 22176 }
16265
16266
5/6
✓ Branch 0 taken 1131656 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1128936 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1153832 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16267 {
16268
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16269 {
16270
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16271 {
16272 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16273 {
16274 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16275 }
16276 }
16277 else
16278 {
16279
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16280 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16281 {
16282 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16283 3902976 }
16284
16285 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16286 }
16287
16288 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16289 3902976 }
16290 22176 }
16291
16292 /*if(version>12)
16293 {
16294 if(!p_getc(&(temp_mapscr->scrWidth),f))
16295 {
16296 return qe_invalid;
16297 }
16298 if(!p_getc(&(temp_mapscr->scrHeight),f))
16299 {
16300 return qe_invalid;
16301 }
16302 }*/
16303
16304
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version>4)
16305 {
16306
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16307 {
16308 return qe_invalid;
16309 }
16310 625328 }
16311 else
16312 {
16313 528504 temp_mapscr->screen_midi = -1;
16314 }
16315
16316
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version>=17)
16317 {
16318
1/2
✓ Branch 0 taken 625328 times.
✗ Branch 1 not taken.
625328 if(!p_getc(&(temp_mapscr->lens_layer),f))
16319 {
16320 return qe_invalid;
16321 }
16322 625328 }
16323 else
16324 {
16325 528504 temp_mapscr->lens_layer = llNORMAL;
16326 }
16327
16328
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 625328 times.
1153832 if(version>6)
16329 {
16330 dword bits;
16331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625328 times.
625328 if(!p_igetl(&bits,f))
16332 {
16333 return qe_invalid;
16334 }
16335
16336 int32_t m;
16337 float tempfloat;
16338 word tempw;
16339 625328 temp_mapscr->ffcCountMarkDirty();
16340
16341
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 20010496 times.
20635824 for(m=0; m<32; m++)
16342 {
16343 20010496 ffcdata& tempffc = temp_mapscr->ffcs[m];
16344 20010496 tempffc.clear();
16345
2/2
✓ Branch 0 taken 19750936 times.
✓ Branch 1 taken 259560 times.
20010496 if((bits>>m)&1)
16346 {
16347
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(!p_igetw(&tempw,f))
16348 {
16349 return qe_invalid;
16350 }
16351 259560 tempffc.data = tempw;
16352
16353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_getc(&(tempffc.cset),f))
16354 {
16355 return qe_invalid;
16356 }
16357
16358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetw(&(tempffc.delay),f))
16359 {
16360 return qe_invalid;
16361 }
16362
16363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(version < 9)
16364 {
16365 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16366 {
16367 return qe_invalid;
16368 }
16369
16370 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16371
16372 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16373 {
16374 return qe_invalid;
16375 }
16376
16377 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16378
16379 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16380 {
16381 return qe_invalid;
16382 }
16383
16384 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16385
16386 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16387 {
16388 return qe_invalid;
16389 }
16390
16391 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16392
16393 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16394 {
16395 return qe_invalid;
16396 }
16397
16398 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16399
16400 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16401 {
16402 return qe_invalid;
16403 }
16404
16405 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16406 }
16407 else
16408 {
16409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetzf(&(tempffc.x),f))
16410 {
16411 return qe_invalid;
16412 }
16413
16414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetzf(&(tempffc.y),f))
16415 {
16416 return qe_invalid;
16417 }
16418
16419
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(!p_igetzf(&(tempffc.vx),f))
16420 {
16421 return qe_invalid;
16422 }
16423
16424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetzf(&(tempffc.vy),f))
16425 {
16426 return qe_invalid;
16427 }
16428
16429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetzf(&(tempffc.ax),f))
16430 {
16431 return qe_invalid;
16432 }
16433
16434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetzf(&(tempffc.ay),f))
16435 {
16436 return qe_invalid;
16437 }
16438 }
16439
16440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_getc(&(tempffc.link),f))
16441 {
16442 return qe_invalid;
16443 }
16444
16445
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(version>7)
16446 {
16447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_getc(&tempbyte,f))
16448 {
16449 return qe_invalid;
16450 }
16451
16452 259560 tempffc.hit_width = (tempbyte&0x3F)+1;
16453 259560 tempffc.txsz = (tempbyte>>6)+1;
16454
16455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_getc(&tempbyte,f))
16456 {
16457 return qe_invalid;
16458 }
16459
16460 259560 tempffc.hit_height = (tempbyte&0x3F)+1;
16461 259560 tempffc.tysz = (tempbyte>>6)+1;
16462
16463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.flags),f))
16464 {
16465 return qe_invalid;
16466 }
16467 259560 }
16468 else
16469 {
16470 tempffc.hit_width=16;
16471 tempffc.hit_height=16;
16472 tempffc.txsz=1;
16473 tempffc.tysz=1;
16474 tempffc.flags=0;
16475 }
16476
16477 259560 tempffc.updateSolid();
16478
16479
16480
4/6
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253556 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 253556 times.
259560 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16481 {
16482 tempffc.flags|=ffIGNOREHOLDUP;
16483 }
16484
16485
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(version>9)
16486 {
16487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetw(&(tempffc.script),f))
16488 {
16489 return qe_invalid;
16490 }
16491 259560 }
16492 else
16493 {
16494 tempffc.script=0;
16495 }
16496
16497
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(version>10)
16498 {
16499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[0]),f))
16500 {
16501 return qe_invalid;
16502 }
16503
16504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[1]),f))
16505 {
16506 return qe_invalid;
16507 }
16508
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[2]),f))
16510 {
16511 return qe_invalid;
16512 }
16513
16514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[3]),f))
16515 {
16516 return qe_invalid;
16517 }
16518
16519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[4]),f))
16520 {
16521 return qe_invalid;
16522 }
16523
16524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[5]),f))
16525 {
16526 return qe_invalid;
16527 }
16528
16529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[6]),f))
16530 {
16531 return qe_invalid;
16532 }
16533
16534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_igetl(&(tempffc.initd[7]),f))
16535 {
16536 return qe_invalid;
16537 }
16538
16539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_getc(&(tempbyte),f))
16540 {
16541 return qe_invalid;
16542 }
16543
16544 259560 tempffc.inita[0]=tempbyte*10000;
16545
16546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259560 times.
259560 if(!p_getc(&(tempbyte),f))
16547 {
16548 return qe_invalid;
16549 }
16550
16551 259560 tempffc.inita[1]=tempbyte*10000;
16552 259560 }
16553 else
16554 {
16555 tempffc.inita[0] = 10000;
16556 tempffc.inita[1] = 10000;
16557 }
16558
16559
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16560 {
16561 tempffc.script = 0;
16562 for(int q = 0; q < 8; ++q)
16563 tempffc.initd[q] = 0;
16564 }
16565
1/2
✓ Branch 0 taken 259560 times.
✗ Branch 1 not taken.
259560 if(version <= 11)
16566 {
16567 fixffcs=true;
16568 }
16569 259560 }
16570 20010496 }
16571
2/2
✓ Branch 0 taken 60031488 times.
✓ Branch 1 taken 625328 times.
60656816 for(m = 32; m < MAXFFCS; ++m)
16572 {
16573 60031488 temp_mapscr->ffcs[m].clear();
16574 60031488 }
16575 625328 }
16576
16577 //add in the new whistle flags
16578
2/2
✓ Branch 0 taken 625328 times.
✓ Branch 1 taken 528504 times.
1153832 if(version<13)
16579 {
16580
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16581 {
16582 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16583 124 }
16584 528504 }
16585
16586 //2.55 starts here
16587
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1119424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1153832 if ( version >= 19 && Header->zelda_version > 0x253 )
16588 {
16589
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16590 {
16591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16592 {
16593 return qe_invalid;
16594 }
16595 344080 }
16596
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16597 {
16598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16599 {
16600 return qe_invalid;
16601 }
16602 344080 }
16603
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16604 {
16605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16606 {
16607 return qe_invalid;
16608 }
16609 344080 }
16610
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 344080 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16611 {
16612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16613 {
16614 return qe_invalid;
16615 }
16616 344080 }
16617 34408 }
16618
3/4
✓ Branch 0 taken 1119424 times.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1119424 times.
1153832 if ( version < 19 && Header->zelda_version > 0x253 )
16619 {
16620 for ( int32_t q = 0; q < 10; q++ )
16621 {
16622 temp_mapscr->npcstrings[q] = 0;
16623 temp_mapscr->new_items[q] = 0;
16624 temp_mapscr->new_item_x[q] = 0;
16625 temp_mapscr->new_item_y[q] = 0;
16626 }
16627 }
16628
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1119424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1153832 if ( version >= 20 && Header->zelda_version > 0x253 )
16629 {
16630
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16631 {
16632 return qe_invalid;
16633 }
16634
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16635 {
16636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16637 {
16638 return qe_invalid;
16639 }
16640 275264 }
16641 34408 }
16642
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1119424 times.
1153832 if ( version < 20 )
16643 {
16644 1119424 temp_mapscr->script = 0;
16645
2/2
✓ Branch 0 taken 8955392 times.
✓ Branch 1 taken 1119424 times.
10074816 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16646 1119424 }
16647
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1119424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1153832 if ( version >= 21 && Header->zelda_version > 0x253 )
16648 {
16649
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16650 {
16651 return qe_invalid;
16652 }
16653 34408 }
16654
2/2
✓ Branch 0 taken 1119424 times.
✓ Branch 1 taken 34408 times.
1153832 if ( version < 21 )
16655 {
16656 1119424 temp_mapscr->preloadscript = 0;
16657 1119424 }
16658 //all builds with version > 20 need this. -Z
16659
16660
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1119424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1153832 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16661 {
16662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16663 {
16664 return qe_invalid;
16665 }
16666
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16667 {
16668 return qe_invalid;
16669 }
16670 34408 }
16671
2/2
✓ Branch 0 taken 1119424 times.
✓ Branch 1 taken 34408 times.
1153832 if ( version < 22 )
16672 {
16673 1119424 temp_mapscr->hidelayers = 0;
16674 1119424 temp_mapscr->hidescriptlayers = 0;
16675 1119424 }
16676
16677 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16678 //May be any version before 2.11. -Z
16679 /* --not the roar, the HIT SFX
16680 if ( Header->zelda_version <= 0x210 )
16681 {
16682 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16683 {
16684 temp_mapscr->bosssfx = WAV_ROAR;
16685 }
16686 }
16687 */
16688
2/2
✓ Branch 0 taken 4615328 times.
✓ Branch 1 taken 1153832 times.
5769160 for(int32_t k=0; k<4; k++)
16689 {
16690
1/2
✓ Branch 0 taken 4615328 times.
✗ Branch 1 not taken.
4615328 if(temp_mapscr->door[k] == dNONE)
16691 temp_mapscr->door[k] = dWALL;
16692 4615328 }
16693
16694 1153832 return 0;
16695 1153832 }
16696 1329680 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16697 {
16698
2/2
✓ Branch 0 taken 1153832 times.
✓ Branch 1 taken 175848 times.
1329680 if(version < 23)
16699 {
16700 1153832 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1153832 times.
1153832 if(ret) return ret;
16702 1153832 }
16703 else
16704 {
16705
1/2
✓ Branch 0 taken 175848 times.
✗ Branch 1 not taken.
175848 if(!p_getc(&(temp_mapscr->valid),f))
16706 return qe_invalid;
16707
2/2
✓ Branch 0 taken 131297 times.
✓ Branch 1 taken 44551 times.
175848 if(!(temp_mapscr->valid & mVALID))
16708 {
16709 131297 int map = scrind/MAPSCRS;
16710 131297 int scr = scrind%MAPSCRS;
16711
4/6
✓ Branch 0 taken 123935 times.
✓ Branch 1 taken 7362 times.
✓ Branch 2 taken 123935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123935 times.
✗ Branch 5 not taken.
131297 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16712 {
16713 //Empty screen, apply autolayers
16714
2/2
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 123935 times.
139091 for(int q = 0; q < 6; ++q)
16715 {
16716 15156 auto layermap = map_autolayers[map*6+q];
16717 15156 temp_mapscr->layermap[q] = layermap;
16718 15156 if(layermap)
16719 15156 temp_mapscr->layerscreen[q] = scr;
16720 15156 }
16721 123935 }
16722 131297 return 0;
16723 }
16724 uint32_t scr_has_flags;
16725
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_igetl(&scr_has_flags,f))
16726 return qe_invalid;
16727
16728
2/2
✓ Branch 0 taken 10470 times.
✓ Branch 1 taken 34081 times.
44551 if(scr_has_flags & SCRHAS_ROOMDATA)
16729 {
16730
1/2
✓ Branch 0 taken 34081 times.
✗ Branch 1 not taken.
34081 if(!p_getc(&(temp_mapscr->guy),f))
16731 return qe_invalid;
16732
2/2
✓ Branch 0 taken 33961 times.
✓ Branch 1 taken 120 times.
34081 if(version > 26)
16733 {
16734
1/2
✓ Branch 0 taken 33961 times.
✗ Branch 1 not taken.
33961 if(!p_igetl(&(temp_mapscr->guytile),f))
16735 return qe_invalid;
16736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33961 times.
33961 if(!p_getc(&(temp_mapscr->guycs),f))
16737 return qe_invalid;
16738
1/2
✓ Branch 0 taken 33961 times.
✗ Branch 1 not taken.
33961 if(!p_igetw(&(temp_mapscr->roomflags),f))
16739 return qe_invalid;
16740 33961 }
16741 else
16742 {
16743 120 temp_mapscr->guytile = -1; //signal to use default guy values
16744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16745
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16746 }
16747
1/2
✓ Branch 0 taken 34081 times.
✗ Branch 1 not taken.
34081 if(!p_igetw(&(temp_mapscr->str),f))
16748 return qe_invalid;
16749
1/2
✓ Branch 0 taken 34081 times.
✗ Branch 1 not taken.
34081 if(!p_getc(&(temp_mapscr->room),f))
16750 return qe_invalid;
16751
1/2
✓ Branch 0 taken 34081 times.
✗ Branch 1 not taken.
34081 if(!p_igetw(&(temp_mapscr->catchall),f))
16752 return qe_invalid;
16753 34081 }
16754
2/2
✓ Branch 0 taken 42757 times.
✓ Branch 1 taken 1794 times.
44551 if(scr_has_flags & SCRHAS_ITEM)
16755 {
16756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if(!p_getc(&(temp_mapscr->item),f))
16757 return qe_invalid;
16758
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if(!p_getc(&(temp_mapscr->hasitem),f))
16759 return qe_invalid;
16760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if(!p_getc(&(temp_mapscr->itemx),f))
16761 return qe_invalid;
16762
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if(!p_getc(&(temp_mapscr->itemy),f))
16763 return qe_invalid;
16764 1794 }
16765
2/2
✓ Branch 0 taken 36275 times.
✓ Branch 1 taken 8276 times.
44551 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16766 {
16767
1/2
✓ Branch 0 taken 8276 times.
✗ Branch 1 not taken.
8276 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16768 return qe_invalid;
16769 8276 }
16770
2/2
✓ Branch 0 taken 42458 times.
✓ Branch 1 taken 2093 times.
44551 if(scr_has_flags & SCRHAS_TWARP)
16771 {
16772
2/2
✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 2093 times.
10465 for(int32_t i=0; i<4; i++)
16773 {
16774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8372 times.
8372 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16775 return qe_invalid;
16776 8372 }
16777
2/2
✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 2093 times.
10465 for(int32_t i=0; i<4; i++)
16778 {
16779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8372 times.
8372 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16780 return qe_invalid;
16781 8372 }
16782
2/2
✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 2093 times.
10465 for(int32_t i=0; i<4; i++)
16783 {
16784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8372 times.
8372 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16785 return qe_invalid;
16786 8372 }
16787
1/2
✓ Branch 0 taken 2093 times.
✗ Branch 1 not taken.
2093 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16788 return qe_invalid;
16789 2093 }
16790
2/2
✓ Branch 0 taken 37937 times.
✓ Branch 1 taken 6614 times.
44551 if(scr_has_flags & SCRHAS_SWARP)
16791 {
16792
2/2
✓ Branch 0 taken 26456 times.
✓ Branch 1 taken 6614 times.
33070 for(int32_t i=0; i<4; i++)
16793 {
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26456 times.
26456 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16795 return qe_invalid;
16796 26456 }
16797
2/2
✓ Branch 0 taken 26456 times.
✓ Branch 1 taken 6614 times.
33070 for(int32_t i=0; i<4; i++)
16798 {
16799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26456 times.
26456 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16800 return qe_invalid;
16801 26456 }
16802
2/2
✓ Branch 0 taken 26456 times.
✓ Branch 1 taken 6614 times.
33070 for(int32_t i=0; i<4; i++)
16803 {
16804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26456 times.
26456 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16805 return qe_invalid;
16806 26456 }
16807
1/2
✓ Branch 0 taken 6614 times.
✗ Branch 1 not taken.
6614 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16808 return qe_invalid;
16809
1/2
✓ Branch 0 taken 6614 times.
✗ Branch 1 not taken.
6614 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16810 return qe_invalid;
16811 6614 }
16812
2/2
✓ Branch 0 taken 39771 times.
✓ Branch 1 taken 4780 times.
44551 if(scr_has_flags & SCRHAS_WARPRET)
16813 {
16814
2/2
✓ Branch 0 taken 19120 times.
✓ Branch 1 taken 4780 times.
23900 for(int32_t i=0; i<4; i++)
16815 {
16816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19120 times.
19120 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16817 return qe_invalid;
16818 19120 }
16819
2/2
✓ Branch 0 taken 19120 times.
✓ Branch 1 taken 4780 times.
23900 for(int32_t i=0; i<4; i++)
16820 {
16821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19120 times.
19120 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16822 return qe_invalid;
16823 19120 }
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4780 times.
4780 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16825 return qe_invalid;
16826
1/2
✓ Branch 0 taken 4780 times.
✗ Branch 1 not taken.
4780 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16827 return qe_invalid;
16828 4780 }
16829
2/2
✓ Branch 0 taken 33925 times.
✓ Branch 1 taken 10626 times.
44551 if(scr_has_flags & SCRHAS_LAYERS)
16830 {
16831
2/2
✓ Branch 0 taken 63756 times.
✓ Branch 1 taken 10626 times.
74382 for(int32_t k=0; k<6; k++)
16832 {
16833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63756 times.
63756 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16834 return qe_invalid;
16835 63756 }
16836
2/2
✓ Branch 0 taken 63756 times.
✓ Branch 1 taken 10626 times.
74382 for(int32_t k=0; k<6; k++)
16837 {
16838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63756 times.
63756 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16839 return qe_invalid;
16840 63756 }
16841
2/2
✓ Branch 0 taken 63756 times.
✓ Branch 1 taken 10626 times.
74382 for(int32_t k=0; k<6; k++)
16842 {
16843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63756 times.
63756 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16844 return qe_invalid;
16845 63756 }
16846
1/2
✓ Branch 0 taken 10626 times.
✗ Branch 1 not taken.
10626 if(!p_getc(&(temp_mapscr->hidelayers),f))
16847 return qe_invalid;
16848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10626 times.
10626 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16849 return qe_invalid;
16850 10626 }
16851
2/2
✓ Branch 0 taken 44549 times.
✓ Branch 1 taken 2 times.
44551 if(scr_has_flags & SCRHAS_MAZE)
16852 {
16853
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t k=0; k<4; k++)
16854 {
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&(temp_mapscr->path[k]),f))
16856 return qe_invalid;
16857 8 }
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_getc(&(temp_mapscr->exitdir),f))
16859 return qe_invalid;
16860 2 }
16861
2/2
✓ Branch 0 taken 19948 times.
✓ Branch 1 taken 24603 times.
44551 if(scr_has_flags & SCRHAS_D_S_U)
16862 {
16863
1/2
✓ Branch 0 taken 19948 times.
✗ Branch 1 not taken.
19948 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16864 return qe_invalid;
16865
2/2
✓ Branch 0 taken 79792 times.
✓ Branch 1 taken 19948 times.
99740 for(int32_t k=0; k<4; k++)
16866 {
16867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79792 times.
79792 if(!p_getc(&(temp_mapscr->door[k]),f))
16868 return qe_invalid;
16869
3/4
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 79416 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
79792 if(version < 29 && temp_mapscr->door[k] == dNONE)
16870 temp_mapscr->door[k] = dWALL;
16871 79792 }
16872
16873
1/2
✓ Branch 0 taken 19948 times.
✗ Branch 1 not taken.
19948 if(!p_getc(&(temp_mapscr->stairx),f))
16874 return qe_invalid;
16875
16876
1/2
✓ Branch 0 taken 19948 times.
✗ Branch 1 not taken.
19948 if(!p_getc(&(temp_mapscr->stairy),f))
16877 return qe_invalid;
16878
1/2
✓ Branch 0 taken 19948 times.
✗ Branch 1 not taken.
19948 if(!p_igetw(&(temp_mapscr->undercombo),f))
16879 return qe_invalid;
16880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19948 times.
19948 if(!p_getc(&(temp_mapscr->undercset),f))
16881 return qe_invalid;
16882 19948 }
16883
2/2
✓ Branch 0 taken 14107 times.
✓ Branch 1 taken 10496 times.
24603 else if(version < 29)
16884 {
16885
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 10496 times.
52480 for(int k = 0; k < 4; ++k)
16886 41984 temp_mapscr->door[k] = dWALL;
16887 10496 }
16888
2/2
✓ Branch 0 taken 38834 times.
✓ Branch 1 taken 5717 times.
44551 if(scr_has_flags & SCRHAS_FLAGS)
16889 {
16890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5717 times.
5717 if(!p_getc(&(temp_mapscr->flags),f))
16891 return qe_invalid;
16892
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->flags2),f))
16893 return qe_invalid;
16894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5717 times.
5717 if(!p_getc(&(temp_mapscr->flags3),f))
16895 return qe_invalid;
16896
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->flags4),f))
16897 return qe_invalid;
16898
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->flags5),f))
16899 return qe_invalid;
16900
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->flags6),f))
16901 return qe_invalid;
16902
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->flags7),f))
16903 return qe_invalid;
16904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5717 times.
5717 if(!p_getc(&(temp_mapscr->flags8),f))
16905 return qe_invalid;
16906
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->flags9),f))
16907 return qe_invalid;
16908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5717 times.
5717 if(!p_getc(&(temp_mapscr->flags10),f))
16909 return qe_invalid;
16910
1/2
✓ Branch 0 taken 5717 times.
✗ Branch 1 not taken.
5717 if(!p_getc(&(temp_mapscr->enemyflags),f))
16911 return qe_invalid;
16912 5717 }
16913
2/2
✓ Branch 0 taken 40045 times.
✓ Branch 1 taken 4506 times.
44551 if(scr_has_flags & SCRHAS_ENEMY)
16914 {
16915
2/2
✓ Branch 0 taken 45060 times.
✓ Branch 1 taken 4506 times.
49566 for(int32_t k=0; k<10; k++)
16916 {
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45060 times.
45060 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16918 return qe_invalid;
16919
1/2
✓ Branch 0 taken 45060 times.
✗ Branch 1 not taken.
45060 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16920 temp_mapscr->enemy[k] = 0;
16921 45060 }
16922
1/2
✓ Branch 0 taken 4506 times.
✗ Branch 1 not taken.
4506 if(!p_getc(&(temp_mapscr->pattern),f))
16923 return qe_invalid;
16924 4506 }
16925
2/2
✓ Branch 0 taken 44233 times.
✓ Branch 1 taken 318 times.
44551 if(scr_has_flags & SCRHAS_CARRY)
16926 {
16927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(!p_igetw(&(temp_mapscr->noreset),f))
16928 return qe_invalid;
16929
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_igetw(&(temp_mapscr->nocarry),f))
16930 return qe_invalid;
16931
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->nextmap),f))
16932 return qe_invalid;
16933
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->nextscr),f))
16934 return qe_invalid;
16935 318 }
16936
2/2
✓ Branch 0 taken 44086 times.
✓ Branch 1 taken 465 times.
44551 if(scr_has_flags & SCRHAS_SCRIPT)
16937 {
16938
1/2
✓ Branch 0 taken 465 times.
✗ Branch 1 not taken.
465 if(!p_igetw(&(temp_mapscr->script),f))
16939 return qe_invalid;
16940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465 times.
465 if(!p_getc(&(temp_mapscr->preloadscript),f))
16941 return qe_invalid;
16942
2/2
✓ Branch 0 taken 3720 times.
✓ Branch 1 taken 465 times.
4185 for ( int32_t q = 0; q < 8; q++ )
16943 {
16944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3720 times.
3720 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16945 return qe_invalid;
16946 3720 }
16947 465 }
16948
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(scr_has_flags & SCRHAS_UNUSED)
16949 {
16950 for ( int32_t q = 0; q < 10; q++ )
16951 {
16952 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16953 return qe_invalid;
16954 }
16955 for ( int32_t q = 0; q < 10; q++ )
16956 {
16957 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16958 return qe_invalid;
16959 }
16960 for ( int32_t q = 0; q < 10; q++ )
16961 {
16962 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16963 return qe_invalid;
16964 }
16965 for ( int32_t q = 0; q < 10; q++ )
16966 {
16967 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16968 return qe_invalid;
16969 }
16970 }
16971
2/2
✓ Branch 0 taken 39649 times.
✓ Branch 1 taken 4902 times.
44551 if(scr_has_flags & SCRHAS_SECRETS)
16972 {
16973
2/2
✓ Branch 0 taken 627456 times.
✓ Branch 1 taken 4902 times.
632358 for(int32_t k=0; k<128; k++)
16974 {
16975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627456 times.
627456 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16976 return qe_invalid;
16977 627456 }
16978
2/2
✓ Branch 0 taken 627456 times.
✓ Branch 1 taken 4902 times.
632358 for(int32_t k=0; k<128; k++)
16979 {
16980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627456 times.
627456 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16981 return qe_invalid;
16982 627456 }
16983
2/2
✓ Branch 0 taken 627456 times.
✓ Branch 1 taken 4902 times.
632358 for(int32_t k=0; k<128; k++)
16984 {
16985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627456 times.
627456 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16986 return qe_invalid;
16987 627456 }
16988 4902 }
16989
2/2
✓ Branch 0 taken 13165 times.
✓ Branch 1 taken 31386 times.
44551 if(scr_has_flags & SCRHAS_COMBOFLAG)
16990 {
16991
2/2
✓ Branch 0 taken 5523936 times.
✓ Branch 1 taken 31386 times.
5555322 for(int32_t k=0; k<176; ++k)
16992 {
16993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5523936 times.
5523936 if(!p_igetw(&(temp_mapscr->data[k]),f))
16994 return qe_invalid;
16995 5523936 }
16996
2/2
✓ Branch 0 taken 5523936 times.
✓ Branch 1 taken 31386 times.
5555322 for(int32_t k=0; k<176; ++k)
16997 {
16998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5523936 times.
5523936 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16999 return qe_invalid;
17000 5523936 }
17001
2/2
✓ Branch 0 taken 5523936 times.
✓ Branch 1 taken 31386 times.
5555322 for(int32_t k=0; k<176; ++k)
17002 {
17003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5523936 times.
5523936 if(!p_getc(&(temp_mapscr->cset[k]),f))
17004 return qe_invalid;
17005 5523936 }
17006 31386 }
17007
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(scr_has_flags & SCRHAS_MISC)
17008 {
17009
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_igetw(&(temp_mapscr->color),f))
17010 return qe_invalid;
17011
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_getc(&(temp_mapscr->csensitive),f))
17012 return qe_invalid;
17013
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_getc(&(temp_mapscr->oceansfx),f))
17014 return qe_invalid;
17015
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_getc(&(temp_mapscr->bosssfx),f))
17016 return qe_invalid;
17017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44551 times.
44551 if(!p_getc(&(temp_mapscr->secretsfx),f))
17018 return qe_invalid;
17019
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17022 return qe_invalid;
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44551 times.
44551 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17024 return qe_invalid;
17025
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_getc(&(temp_mapscr->lens_layer),f))
17026 return qe_invalid;
17027
2/2
✓ Branch 0 taken 10590 times.
✓ Branch 1 taken 33961 times.
44551 if(version > 27)
17028 {
17029
1/2
✓ Branch 0 taken 33961 times.
✗ Branch 1 not taken.
33961 if(!p_getc(&(temp_mapscr->lens_show),f))
17030 return qe_invalid;
17031
1/2
✓ Branch 0 taken 33961 times.
✗ Branch 1 not taken.
33961 if(!p_getc(&(temp_mapscr->lens_hide),f))
17032 return qe_invalid;
17033 33961 }
17034 44551 }
17035 else
17036 {
17037 temp_mapscr->screen_midi = -1;
17038 temp_mapscr->csensitive = 1;
17039 }
17040 //FFC
17041 44551 bool old_ff = version < 25;
17042 44551 dword bits = 0;
17043 44551 word numffc = 32;
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44551 times.
44551 if(old_ff)
17045 {
17046 if(!p_igetl(&bits,f))
17047 return qe_invalid;
17048 }
17049 else
17050 {
17051
1/2
✓ Branch 0 taken 44551 times.
✗ Branch 1 not taken.
44551 if(!p_igetw(&numffc,f))
17052 return qe_invalid;
17053 }
17054 byte tempbyte;
17055 word tempw;
17056
4/6
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 44278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 273 times.
44551 static ffcdata nil_ffc;
17057 44551 temp_mapscr->ffcCountMarkDirty();
17058
2/2
✓ Branch 0 taken 72776 times.
✓ Branch 1 taken 44551 times.
117327 for(word m = 0; m < numffc; ++m)
17059 {
17060
1/2
✓ Branch 0 taken 72776 times.
✗ Branch 1 not taken.
72776 ffcdata& tempffc = (m < MAXFFCS)
17061 72776 ? temp_mapscr->ffcs[m]
17062 : nil_ffc; //sanity
17063 72776 tempffc.clear();
17064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72776 if(old_ff && !(bits & (1<<m))) continue;
17065
17066
1/2
✓ Branch 0 taken 72776 times.
✗ Branch 1 not taken.
72776 if(!p_igetw(&tempw,f))
17067 return qe_invalid;
17068
3/4
✓ Branch 0 taken 72776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12591 times.
✓ Branch 3 taken 60185 times.
72776 if(!old_ff && !tempw) //empty ffc, nothing more to load
17069 60185 continue;
17070 12591 tempffc.data = tempw;
17071
17072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_getc(&(tempffc.cset),f))
17073 return qe_invalid;
17074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetw(&(tempffc.delay),f))
17075 return qe_invalid;
17076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetzf(&(tempffc.x),f))
17077 return qe_invalid;
17078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetzf(&(tempffc.y),f))
17079 return qe_invalid;
17080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetzf(&(tempffc.vx),f))
17081 return qe_invalid;
17082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetzf(&(tempffc.vy),f))
17083 return qe_invalid;
17084
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetzf(&(tempffc.ax),f))
17085 return qe_invalid;
17086
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetzf(&(tempffc.ay),f))
17087 return qe_invalid;
17088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_getc(&(tempffc.link),f))
17089 return qe_invalid;
17090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(version < 24)
17091 {
17092 if(!p_getc(&tempbyte,f))
17093 return qe_invalid;
17094 tempffc.hit_width = (tempbyte&0x3F)+1;
17095 tempffc.txsz = (tempbyte>>6)+1;
17096 if(!p_getc(&tempbyte,f))
17097 return qe_invalid;
17098 tempffc.hit_height = (tempbyte&0x3F)+1;
17099 tempffc.tysz = (tempbyte>>6)+1;
17100 }
17101 else
17102 {
17103
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetl(&(tempffc.hit_width),f))
17104 return qe_invalid;
17105
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetl(&(tempffc.hit_height),f))
17106 return qe_invalid;
17107
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&(tempffc.txsz),f))
17108 return qe_invalid;
17109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_getc(&(tempffc.tysz),f))
17110 return qe_invalid;
17111 }
17112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetl(&(tempffc.flags),f))
17113 return qe_invalid;
17114 12591 tempffc.updateSolid();
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_igetw(&(tempffc.script),f))
17116 return qe_invalid;
17117
2/2
✓ Branch 0 taken 100728 times.
✓ Branch 1 taken 12591 times.
113319 for(auto q = 0; q < 8; ++q)
17118 {
17119
1/2
✓ Branch 0 taken 100728 times.
✗ Branch 1 not taken.
100728 if(!p_igetl(&(tempffc.initd[q]),f))
17120 return qe_invalid;
17121 100728 }
17122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(!p_getc(&(tempbyte),f))
17123 return qe_invalid;
17124 12591 tempffc.inita[0]=tempbyte*10000;
17125
17126
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&(tempbyte),f))
17127 return qe_invalid;
17128 12591 tempffc.inita[1]=tempbyte*10000;
17129
17130
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17131 {
17132 tempffc.script = 0;
17133 for(int q = 0; q < 8; ++q)
17134 tempffc.initd[q] = 0;
17135 }
17136 12591 }
17137
2/2
✓ Branch 0 taken 5629752 times.
✓ Branch 1 taken 44551 times.
5674303 for(word m = numffc; m < MAXFFCS; ++m)
17138 {
17139 5629752 temp_mapscr->ffcs[m].clear();
17140 5629752 }
17141 //END FFC
17142
2/2
✓ Branch 0 taken 35846 times.
✓ Branch 1 taken 8705 times.
44551 if(version > 29)
17143
1/2
✓ Branch 0 taken 8705 times.
✗ Branch 1 not taken.
8705 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17144 return qe_invalid;
17145 }
17146 1198383 return 0;
17147 1329680 }
17148
17149
17150 687 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17151 {
17152
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17153 687 int32_t scr=0;
17154
17155 687 word version=0;
17156 dword dummy;
17157 int32_t screens_to_read;
17158
17159 687 mapscr temp_mapscr;
17160 word temp_map_count;
17161 dword section_size;
17162
17163
5/6
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 663 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
687 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17164 {
17165 18 screens_to_read=MAPSCRS192b136;
17166 18 }
17167 else
17168 {
17169 669 screens_to_read=MAPSCRS;
17170 }
17171
17172
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if(Header->zelda_version > 0x192)
17173 {
17174 //section version info
17175
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&version,f))
17176 {
17177 return qe_invalid;
17178 }
17179
17180 663 FFCore.quest_format[vMaps] = version;
17181
17182 //al_trace("Maps version %d\n", version);
17183
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&dummy,f))
17184 {
17185 return qe_invalid;
17186 }
17187
17188 //section size
17189
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetl(&section_size,f))
17190 {
17191 return qe_invalid;
17192 }
17193
17194 //finally... section data
17195
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&temp_map_count,f))
17196 {
17197 return 5;
17198 }
17199 663 }
17200 else
17201 {
17202 24 temp_map_count=map_count;
17203 }
17204
17205
2/4
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 687 times.
✗ Branch 3 not taken.
687 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS))
17206 {
17207 return qe_invalid;
17208 }
17209
17210
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if (!should_skip)
17211 {
17212 686 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17213
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 TheMaps.resize(_mapsSize);
17214 686 map_autolayers.clear();
17215
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 map_autolayers.resize(temp_map_count*6);
17216
2/2
✓ Branch 0 taken 1334296 times.
✓ Branch 1 taken 686 times.
1334982 for(int32_t i(0); i<_mapsSize; i++)
17217
1/2
✓ Branch 0 taken 1334296 times.
✗ Branch 1 not taken.
1334296 TheMaps[i].zero_memory();
17218 686 }
17219
17220
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 temp_mapscr.zero_memory();
17221
17222
4/4
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 9813 times.
✓ Branch 2 taken 687 times.
✓ Branch 3 taken 9813 times.
10500 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17223 {
17224 9813 byte valid=1;
17225
2/2
✓ Branch 0 taken 1324 times.
✓ Branch 1 taken 8489 times.
9813 if(version > 22)
17226 {
17227
2/4
✓ Branch 0 taken 1324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1324 times.
✗ Branch 3 not taken.
1324 if(!p_getc(&valid,f))
17228 return qe_invalid;
17229 1324 }
17230
4/4
✓ Branch 0 taken 9782 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 8621 times.
✓ Branch 3 taken 1161 times.
9813 if(valid && version > 25)
17231 {
17232
2/2
✓ Branch 0 taken 6966 times.
✓ Branch 1 taken 1161 times.
8127 for(int q = 0; q < 6; ++q)
17233 {
17234
2/4
✓ Branch 0 taken 6966 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6966 times.
✗ Branch 3 not taken.
6966 if(!p_igetw(&map_autolayers[i*6+q],f))
17235 return qe_invalid;
17236 6966 }
17237 1161 }
17238
2/2
✓ Branch 0 taken 1333896 times.
✓ Branch 1 taken 9813 times.
1343709 for(int32_t j=0; j<screens_to_read; j++)
17239 {
17240 1333896 scr=i*MAPSCRS+j;
17241
1/2
✓ Branch 0 taken 1333896 times.
✗ Branch 1 not taken.
1333896 clear_screen(&temp_mapscr);
17242
2/2
✓ Branch 0 taken 1329680 times.
✓ Branch 1 taken 4216 times.
1333896 if(valid)
17243
1/2
✓ Branch 0 taken 1329680 times.
✗ Branch 1 not taken.
1329680 readmapscreen(f, Header, &temp_mapscr, version, scr);
17244
17245
2/2
✓ Branch 0 taken 1333624 times.
✓ Branch 1 taken 272 times.
1333896 if (!should_skip)
17246
1/2
✓ Branch 0 taken 1333624 times.
✗ Branch 1 not taken.
1333624 TheMaps[scr] = temp_mapscr;
17247 1333896 }
17248
17249
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 2 times.
9813 if (should_skip)
17250 2 continue;
17251
17252
5/6
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9625 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
9811 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17253 {
17254 168 int32_t index = (i*MAPSCRS+132);
17255
17256
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17257
17258 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17259 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17260 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17261
17262
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17263 {
17264 504 scr=i*MAPSCRS+j;
17265
17266
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[scr].zero_memory();
17267 504 TheMaps[scr].valid = mVERSION;
17268 504 TheMaps[scr].screen_midi = -1;
17269 504 TheMaps[scr].csensitive = 1;
17270 504 }
17271 168 }
17272
17273
5/6
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9625 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
9811 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17274 {
17275
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17276 {
17277 22848 scr=i*MAPSCRS+j;
17278 22848 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17279
17280
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17281 {
17282
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17283
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17284
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17285 2924544 }
17286 22848 }
17287 168 }
17288 9811 }
17289 687 map_count = temp_map_count;
17290
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 clear_screen(&temp_mapscr);
17291 687 return 0;
17292 687 }
17293
17294
17295 9756044 void update_combo(newcombo& cmb, word section_version)
17296 {
17297
2/2
✓ Branch 0 taken 2245793 times.
✓ Branch 1 taken 7510251 times.
9756044 if(section_version < 40)
17298 {
17299
3/3
✓ Branch 0 taken 5009 times.
✓ Branch 1 taken 44808 times.
✓ Branch 2 taken 7460434 times.
7510251 switch(cmb.type)
17300 {
17301 case cWATER: case cSHALLOWWATER:
17302 44808 cmb.attribytes[6] = iwRipples;
17303 44808 break;
17304 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17305 5009 cmb.attribytes[6] = iwTallGrass;
17306 5009 break;
17307 }
17308 7510251 }
17309 9756044 }
17310 273 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17311 {
17312
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 24 times.
273 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17313
17314
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 272 times.
273 if (!should_skip)
17315 {
17316 272 reset_combo_animations();
17317 272 reset_combo_animations2();
17318 272 init_combo_classes();
17319 272 }
17320
17321 // combos
17322 273 word combos_used=0;
17323 int32_t dummy;
17324 byte padding;
17325 273 newcombo temp_combo;
17326 //word section_cversion=0;
17327
17328
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 272 times.
273 if (!should_skip)
17329
2/2
✓ Branch 0 taken 17756160 times.
✓ Branch 1 taken 272 times.
17756432 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17330
1/2
✓ Branch 0 taken 17756160 times.
✗ Branch 1 not taken.
17756432 combobuf[q].clear();
17331
17332 // if(version > 0x192)
17333 // {
17334 // //section version info
17335 // if(!p_igetw(&section_version,f))
17336 // {
17337 // return qe_invalid;
17338 // }
17339
17340 // FFCore.quest_format[vCombos] = section_version;
17341
17342 // //al_trace("Combos version %d\n", section_version);
17343 // if(!p_igetw(&section_cversion,f))
17344 // {
17345 // return qe_invalid;
17346 // }
17347
17348 // //section size
17349 // if(!p_igetl(&dummy,f))
17350 // {
17351 // return qe_invalid;
17352 // }
17353 // }
17354
17355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 273 times.
273 if(version < 0x174)
17356 {
17357 combos_used=1024;
17358 }
17359
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 18 times.
273 else if(version < 0x191)
17360 {
17361 18 combos_used=2048;
17362 18 }
17363 else
17364 {
17365
2/4
✓ Branch 0 taken 255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
255 if(!p_igetw(&combos_used,f))
17366 {
17367 return qe_invalid;
17368 }
17369 }
17370
17371 //finally... section data
17372
2/2
✓ Branch 0 taken 7375235 times.
✓ Branch 1 taken 273 times.
7375508 for(int32_t i=0; i<combos_used; i++)
17373 {
17374
1/2
✓ Branch 0 taken 7375235 times.
✗ Branch 1 not taken.
7375235 temp_combo.clear();
17375
17376
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7172267 times.
7375235 if ( section_version >= 11 )
17377 {
17378
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17379 {
17380 return qe_invalid;
17381 }
17382 202968 }
17383 else
17384 {
17385
2/4
✓ Branch 0 taken 7172267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7172267 times.
✗ Branch 3 not taken.
7172267 if(!p_igetw(&temp_combo.tile,f))
17386 {
17387 return qe_invalid;
17388 }
17389 }
17390 7375235 temp_combo.o_tile = temp_combo.tile;
17391
2/4
✓ Branch 0 taken 7375235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7375235 times.
✗ Branch 3 not taken.
7375235 if(!p_getc(&temp_combo.flip,f))
17392 {
17393 return qe_invalid;
17394 }
17395
17396
2/4
✓ Branch 0 taken 7375235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7375235 times.
✗ Branch 3 not taken.
7375235 if(!p_getc(&temp_combo.walk,f))
17397 {
17398 return qe_invalid;
17399 }
17400
17401
2/4
✓ Branch 0 taken 7375235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7375235 times.
✗ Branch 3 not taken.
7375235 if(!p_getc(&temp_combo.type,f))
17402 {
17403 return qe_invalid;
17404 }
17405
17406
2/4
✓ Branch 0 taken 7375235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7375235 times.
✗ Branch 3 not taken.
7375235 if(!p_getc(&temp_combo.csets,f))
17407 {
17408 return qe_invalid;
17409 }
17410
17411
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7305461 times.
7375235 if(version < 0x193)
17412 {
17413
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17414 return qe_invalid;
17415
17416
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17417 return qe_invalid;
17418
17419
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17420 {
17421
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17422 {
17423 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17424 {
17425 if(!p_getc(&padding,f))
17426 return qe_invalid;
17427 }
17428 }
17429 36864 }
17430 69774 }
17431
2/2
✓ Branch 0 taken 7338371 times.
✓ Branch 1 taken 36864 times.
7375235 if(version >= 0x192)
17432 {
17433
2/4
✓ Branch 0 taken 7338371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7338371 times.
✗ Branch 3 not taken.
7338371 if(!p_getc(&temp_combo.frames,f))
17434 return qe_invalid;
17435
17436
2/4
✓ Branch 0 taken 7338371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7338371 times.
✗ Branch 3 not taken.
7338371 if(!p_getc(&temp_combo.speed,f))
17437 return qe_invalid;
17438
17439
2/4
✓ Branch 0 taken 7338371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7338371 times.
✗ Branch 3 not taken.
7338371 if(!p_igetw(&temp_combo.nextcombo,f))
17440 return qe_invalid;
17441
17442
2/4
✓ Branch 0 taken 7338371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7338371 times.
✗ Branch 3 not taken.
7338371 if(!p_getc(&temp_combo.nextcset,f))
17443 return qe_invalid;
17444
17445 //Base flag
17446
2/2
✓ Branch 0 taken 4449963 times.
✓ Branch 1 taken 2888408 times.
7338371 if(section_version>=3)
17447
2/4
✓ Branch 0 taken 4449963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4449963 times.
✗ Branch 3 not taken.
4449963 if(!p_getc(&temp_combo.flag,f))
17448 return qe_invalid;
17449
17450
2/2
✓ Branch 0 taken 4449963 times.
✓ Branch 1 taken 2888408 times.
7338371 if(section_version>=4)
17451 {
17452
2/4
✓ Branch 0 taken 4449963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4449963 times.
✗ Branch 3 not taken.
4449963 if(!p_getc(&temp_combo.skipanim,f))
17453 return qe_invalid;
17454
17455
2/4
✓ Branch 0 taken 4449963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4449963 times.
✗ Branch 3 not taken.
4449963 if(!p_igetw(&temp_combo.nexttimer,f))
17456 return qe_invalid;
17457 4449963 }
17458
17459
2/2
✓ Branch 0 taken 4449963 times.
✓ Branch 1 taken 2888408 times.
7338371 if(section_version>=5)
17460
2/4
✓ Branch 0 taken 4449963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4449963 times.
✗ Branch 3 not taken.
4449963 if(!p_getc(&temp_combo.skipanimy,f))
17461 return qe_invalid;
17462
17463
2/2
✓ Branch 0 taken 4449963 times.
✓ Branch 1 taken 2888408 times.
7338371 if(section_version>=6)
17464 {
17465
2/4
✓ Branch 0 taken 4449963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4449963 times.
✗ Branch 3 not taken.
4449963 if(!p_getc(&temp_combo.animflags,f))
17466 return qe_invalid;
17467
17468
1/2
✓ Branch 0 taken 4449963 times.
✗ Branch 1 not taken.
4449963 if(section_version == 6)
17469 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17470 4449963 }
17471
17472
2/2
✓ Branch 0 taken 7135403 times.
✓ Branch 1 taken 202968 times.
7338371 if(section_version>=8) //combo Attributes[4] and userflags.
17473 {
17474
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17475
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17476 return qe_invalid;
17477
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17478 return qe_invalid;
17479
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17480
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17481 return qe_invalid;
17482 202968 }
17483
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7135403 times.
7338371 if(section_version>=10) //combo trigger flags
17484 {
17485
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17486
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_combo.triggerflags[q],f))
17487 return qe_invalid;
17488 202968 }
17489
1/2
✓ Branch 0 taken 7135403 times.
✗ Branch 1 not taken.
7135403 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17490 {
17491 for ( int32_t q = 0; q < 2; q++ )
17492 if(!p_igetl(&temp_combo.triggerflags[q],f))
17493 return qe_invalid;
17494 }
17495
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7135403 times.
7338371 if(section_version >= 9)
17496
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.triggerlevel,f))
17497 return qe_invalid;
17498
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7135403 times.
7338371 if(section_version >= 22)
17499
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.triggerbtn,f))
17500 return qe_invalid;
17501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 24)
17502 {
17503 if(!p_getc(&temp_combo.triggeritem,f))
17504 return qe_invalid;
17505 if(!p_getc(&temp_combo.trigtimer,f))
17506 return qe_invalid;
17507 }
17508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 25)
17509 if(!p_getc(&temp_combo.trigsfx,f))
17510 return qe_invalid;
17511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 27)
17512 if(!p_igetl(&temp_combo.trigchange,f))
17513 return qe_invalid;
17514
17515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 29)
17516 {
17517 if(!p_igetw(&temp_combo.trigprox,f))
17518 return qe_invalid;
17519 if(!p_getc(&temp_combo.trigctr,f))
17520 return qe_invalid;
17521 if(!p_igetl(&temp_combo.trigctramnt,f))
17522 return qe_invalid;
17523 }
17524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 30)
17525 if(!p_getc(&temp_combo.triglbeam,f))
17526 return qe_invalid;
17527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 31)
17528 {
17529 if(!p_getc(&temp_combo.trigcschange,f))
17530 return qe_invalid;
17531 if(!p_igetw(&temp_combo.spawnitem,f))
17532 return qe_invalid;
17533 if(!p_igetw(&temp_combo.spawnenemy,f))
17534 return qe_invalid;
17535 if(!p_getc(&temp_combo.exstate,f))
17536 return qe_invalid;
17537 if(!p_igetl(&temp_combo.spawnip,f))
17538 return qe_invalid;
17539 if(!p_getc(&temp_combo.trigcopycat,f))
17540 return qe_invalid;
17541 }
17542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7338371 times.
7338371 if(section_version >= 32)
17543 if(!p_getc(&temp_combo.trigcooldown,f))
17544 return qe_invalid;
17545
17546
2/2
✓ Branch 0 taken 7135403 times.
✓ Branch 1 taken 202968 times.
7338371 if(section_version>=12) //combo label
17547 {
17548 char label[12];
17549 202968 label[11] = '\0';
17550
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17551
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17552 return qe_invalid;
17553
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17554 202968 }
17555
2/2
✓ Branch 0 taken 7135403 times.
✓ Branch 1 taken 202968 times.
7338371 if(section_version>=13) //attribytes[4]
17556
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17557
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17558 202968 return qe_invalid;
17559 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17560 * This fixes a poor implementation of a ->next flag bug thing.
17561 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17562 * there was a version bump a few weeks before a change that broke stuff.
17563 */
17564
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7135403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7338371 if (section_version >= 13 && section_version < 21)
17565 {
17566 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17567 }
17568 //combo scripts
17569
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7135403 times.
7338371 if(section_version>=14)
17570 {
17571
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17572 return qe_invalid;
17573
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17574
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17575 return qe_invalid;
17576 202968 }
17577 //al_trace("Read combo script data\n");
17578
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7135403 times.
7338371 if(section_version>=15)
17579 {
17580
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17581
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17582
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17583
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17584 202968 }
17585
2/2
✓ Branch 0 taken 7135403 times.
✓ Branch 1 taken 202968 times.
7338371 if(section_version>=17) //attribytes[4]
17586 {
17587
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17588
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17589 return qe_invalid;
17590
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17591
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17592 return qe_invalid;
17593 202968 }
17594
17595
2/2
✓ Branch 0 taken 7305461 times.
✓ Branch 1 taken 32910 times.
7338371 if(version < 0x193)
17596
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17597
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17598 32910 return qe_invalid;
17599 7338371 }
17600
17601 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17602
3/6
✓ Branch 0 taken 4449963 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4449963 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7375235 if((version < 0x211)||((version == 0x211)&&(build<7)))
17603 {
17604
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17605 {
17606
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17607 {
17608 case 130:
17609 temp_combo.tile = 132;
17610 break;
17611
17612 case 131:
17613 temp_combo.tile = 133;
17614 break;
17615
17616 case 132:
17617 temp_combo.tile = 130;
17618 break;
17619
17620 case 133:
17621 temp_combo.tile = 131;
17622 break;
17623 }
17624 39936 }
17625 2925272 }
17626
17627
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7172267 times.
7375235 if(section_version < 15)
17628 7172267 temp_combo.o_tile = temp_combo.tile;
17629
17630
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7172267 times.
7375235 if(section_version<18) //upper bits for .walk
17631 7172267 temp_combo.walk |= 0xF0;
17632
17633
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7172267 times.
7375235 if(section_version < 19)
17634
2/2
✓ Branch 0 taken 28689068 times.
✓ Branch 1 taken 7172267 times.
35861335 for(int32_t q = 0; q < 4; ++q)
17635 35861335 temp_combo.attributes[q] *= 10000L;
17636
17637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 if(section_version < 23)
17638 {
17639
2/2
✓ Branch 0 taken 14731 times.
✓ Branch 1 taken 7360504 times.
7375235 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17640 {
17641 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17642 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17643 case cTRIGGERGENERIC: case cCSWITCH:
17644 14731 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17645 14731 }
17646 7375235 }
17647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 if(section_version < 25)
17648 {
17649
2/2
✓ Branch 0 taken 26727 times.
✓ Branch 1 taken 7348508 times.
7375235 switch(temp_combo.type)
17650 {
17651 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26727 times.
26727 if(!(temp_combo.usrflags & cflag3))
17653 26727 temp_combo.attribytes[3] = WAV_DOOR;
17654 26727 temp_combo.usrflags &= ~cflag3;
17655 26727 break;
17656 }
17657 7375235 }
17658
17659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 if(section_version < 26)
17660
2/2
✓ Branch 0 taken 7374163 times.
✓ Branch 1 taken 1072 times.
7376307 if(temp_combo.type == cARMOS)
17661
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
1072 if(temp_combo.usrflags & cflag1)
17662 temp_combo.usrflags |= cflag3;
17663
17664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 if(section_version < 27)
17665 {
17666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17667 temp_combo.trigchange = 1;
17668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17669 temp_combo.trigchange = -1;
17670 7375235 else temp_combo.trigchange = 0;
17671 7375235 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17672 7375235 }
17673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7375235 times.
7375235 if(section_version < 28)
17674 {
17675
2/2
✓ Branch 0 taken 14992 times.
✓ Branch 1 taken 7360243 times.
7375235 switch(temp_combo.type)
17676 {
17677 case cLOCKBLOCK: case cLOCKEDCHEST:
17678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14992 times.
14992 if(temp_combo.usrflags & cflag7)
17679 temp_combo.usrflags |= cflag8;
17680 14992 else temp_combo.usrflags &= ~cflag8;
17681 14992 temp_combo.usrflags &= ~cflag7;
17682 14992 break;
17683 }
17684
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 7374504 times.
7375235 switch(temp_combo.type)
17685 {
17686 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17687 731 temp_combo.attrishorts[2] = -1;
17688 731 temp_combo.usrflags |= cflag7;
17689 731 break;
17690 }
17691 7375235 }
17692
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7172267 times.
7375235 if(section_version < 20)
17693 {
17694 7172267 temp_combo.genflags = 0;
17695
2/2
✓ Branch 0 taken 141258 times.
✓ Branch 1 taken 7031009 times.
7172267 switch(temp_combo.type)
17696 {
17697 case cPUSH_WAIT: case cPUSH_HEAVY:
17698 case cPUSH_HW: case cL_STATUE:
17699 case cR_STATUE: case cPUSH_HEAVY2:
17700 case cPUSH_HW2: case cPOUND:
17701 case cC_STATUE: case cMIRROR:
17702 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17703 case cMAGICPRISM: case cMAGICPRISM4:
17704 case cMAGICSPONGE: case cEYEBALL_A:
17705 case cEYEBALL_B: case cEYEBALL_4:
17706 case cBUSH: case cFLOWERS:
17707 case cLOCKBLOCK: case cLOCKBLOCK2:
17708 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17709 case cCHEST: case cCHEST2:
17710 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17711 case cBOSSCHEST: case cBOSSCHEST2:
17712 case cBUSHNEXT: case cBUSHTOUCHY:
17713 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17714 case cSIGNPOST: case cCSWITCHBLOCK:
17715 case cTORCH: case cTRIGGERGENERIC:
17716
1/2
✓ Branch 0 taken 141258 times.
✗ Branch 1 not taken.
141258 if(temp_combo.usrflags & cflag16)
17717 {
17718 temp_combo.genflags |= cflag1;
17719 temp_combo.usrflags &= ~cflag16;
17720 }
17721 141258 break;
17722 }
17723 7172267 }
17724
17725 7375235 update_combo(temp_combo, section_version);
17726
17727
3/4
✓ Branch 0 taken 7375235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7360316 times.
✓ Branch 3 taken 14919 times.
7375235 if(i>=start_combo && !should_skip)
17728 {
17729
1/2
✓ Branch 0 taken 7360316 times.
✗ Branch 1 not taken.
7360316 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17730 {
17731 temp_combo.script = 0;
17732 for(int q = 0; q < 8; ++q)
17733 temp_combo.initd[q] = 0;
17734 }
17735
1/2
✓ Branch 0 taken 7360316 times.
✗ Branch 1 not taken.
7360316 combobuf[i] = temp_combo;
17736 7360316 }
17737 7375235 }
17738
17739
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1 times.
273 if (should_skip)
17740 1 return 0;
17741
17742
5/6
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
272 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17743 {
17744
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17745 {
17746
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17747 {
17748 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17749 215 }
17750 1501440 }
17751 23 }
17752
17753 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17754
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 213 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
272 if(version == 0x210 && !is_editor())
17755 {
17756
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17757
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17758 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17759 59 }
17760
17761
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 82 times.
272 if(section_version<7)
17762 {
17763
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17764 {
17765
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17766 {
17767 case cSLASH:
17768 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17769 853 break;
17770
17771 case cSLASHITEM:
17772 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17773 791 break;
17774
17775 case cBUSH:
17776 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17777 603 break;
17778
17779 case cFLOWERS:
17780 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17781 174 break;
17782
17783 case cTALLGRASS:
17784 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17785 531 break;
17786
17787 case cSLASHNEXT:
17788 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17789 break;
17790
17791 case cSLASHNEXTITEM:
17792 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17793 break;
17794
17795 case cBUSHNEXT:
17796 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17797 break;
17798 }
17799 5352960 }
17800 82 }
17801
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 267 times.
272 if (section_version < 16)
17802 {
17803
2/2
✓ Branch 0 taken 17429760 times.
✓ Branch 1 taken 267 times.
17430027 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17804 {
17805
2/2
✓ Branch 0 taken 17401283 times.
✓ Branch 1 taken 28477 times.
17429760 if (combobuf[tmpcounter].type == cWATER)
17806 {
17807 28477 combobuf[tmpcounter].attributes[0] = 40000L;
17808 28477 }
17809 17429760 }
17810 267 }
17811
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 3 times.
272 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17812 {
17813 3 combobuf[0].walk = 0xF0;
17814 3 combobuf[0].type = 0;
17815 3 combobuf[0].flag = 0;
17816 3 }
17817
17818 //Now for the new combo alias reset
17819
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 82 times.
272 if(section_version<2)
17820 {
17821
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17822 {
17823 671744 combo_aliases[j].width = 0;
17824 671744 combo_aliases[j].height = 0;
17825 671744 combo_aliases[j].layermask = 0;
17826
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17827
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17828 671744 }
17829 82 }
17830
17831
17832
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 setup_combo_animations();
17833
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 setup_combo_animations2();
17834 272 return 0;
17835 273 }
17836 2380809 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17837 {
17838 byte combo_has_flags;
17839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2380809 times.
2380809 if(!p_getc(&combo_has_flags,f))
17840 return qe_invalid;
17841
17842 2380809 temp_combo.clear();
17843
2/2
✓ Branch 0 taken 1660202 times.
✓ Branch 1 taken 720607 times.
2380809 if(combo_has_flags)
17844 {
17845
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 720550 times.
720607 if(combo_has_flags&CHAS_BASIC)
17846 {
17847
1/2
✓ Branch 0 taken 720550 times.
✗ Branch 1 not taken.
720550 if(!p_igetl(&temp_combo.tile,f))
17848 return qe_invalid;
17849 720550 temp_combo.o_tile = temp_combo.tile;
17850
17851
1/2
✓ Branch 0 taken 720550 times.
✗ Branch 1 not taken.
720550 if(!p_getc(&temp_combo.flip,f))
17852 return qe_invalid;
17853
17854
1/2
✓ Branch 0 taken 720550 times.
✗ Branch 1 not taken.
720550 if(!p_getc(&temp_combo.walk,f))
17855 return qe_invalid;
17856
17857
1/2
✓ Branch 0 taken 720550 times.
✗ Branch 1 not taken.
720550 if(!p_getc(&temp_combo.type,f))
17858 return qe_invalid;
17859
17860
1/2
✓ Branch 0 taken 720550 times.
✗ Branch 1 not taken.
720550 if(!p_getc(&temp_combo.flag,f))
17861 return qe_invalid;
17862
17863
1/2
✓ Branch 0 taken 720550 times.
✗ Branch 1 not taken.
720550 if(!p_getc(&temp_combo.csets,f))
17864 return qe_invalid;
17865 720550 }
17866
2/2
✓ Branch 0 taken 717795 times.
✓ Branch 1 taken 2812 times.
720607 if(combo_has_flags&CHAS_SCRIPT)
17867 {
17868
2/2
✓ Branch 0 taken 2782 times.
✓ Branch 1 taken 30 times.
2812 if (s_version>=41)
17869 {
17870 2782 p_getcstr(&temp_combo.label, f);
17871 2782 }
17872 else
17873 {
17874 char label[12];
17875 30 label[11] = '\0';
17876
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
17877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(!p_getc(&label[q],f))
17878 return qe_invalid;
17879 30 temp_combo.label = label;
17880 }
17881
17882
1/2
✓ Branch 0 taken 2812 times.
✗ Branch 1 not taken.
2812 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17883 2812 auto initd_count = s_version >= 43 ? 8 : 2;
17884
2/2
✓ Branch 0 taken 22316 times.
✓ Branch 1 taken 2812 times.
25128 for ( int32_t q = 0; q < initd_count; q++ )
17885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22316 times.
22316 if(!p_igetl(&temp_combo.initd[q],f))
17886 return qe_invalid;
17887 2812 }
17888
2/2
✓ Branch 0 taken 572713 times.
✓ Branch 1 taken 147894 times.
720607 if(combo_has_flags&CHAS_ANIM)
17889 {
17890
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_getc(&temp_combo.frames,f))
17891 return qe_invalid;
17892
17893
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_getc(&temp_combo.speed,f))
17894 return qe_invalid;
17895
17896
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_igetw(&temp_combo.nextcombo,f))
17897 return qe_invalid;
17898
17899
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_getc(&temp_combo.nextcset,f))
17900 return qe_invalid;
17901
17902
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_getc(&temp_combo.skipanim,f))
17903 return qe_invalid;
17904
17905
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_getc(&temp_combo.skipanimy,f))
17906 return qe_invalid;
17907
17908
1/2
✓ Branch 0 taken 147894 times.
✗ Branch 1 not taken.
147894 if(!p_getc(&temp_combo.animflags,f))
17909 return qe_invalid;
17910 147894 }
17911
2/2
✓ Branch 0 taken 638958 times.
✓ Branch 1 taken 81649 times.
720607 if(combo_has_flags&CHAS_ATTRIB)
17912 {
17913
2/2
✓ Branch 0 taken 326596 times.
✓ Branch 1 taken 81649 times.
408245 for ( int32_t q = 0; q < 4; q++ )
17914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326596 times.
326596 if(!p_igetl(&temp_combo.attributes[q],f))
17915 return qe_invalid;
17916
2/2
✓ Branch 0 taken 653192 times.
✓ Branch 1 taken 81649 times.
734841 for ( int32_t q = 0; q < 8; q++ )
17917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653192 times.
653192 if(!p_getc(&temp_combo.attribytes[q],f))
17918 return qe_invalid;
17919
2/2
✓ Branch 0 taken 653192 times.
✓ Branch 1 taken 81649 times.
734841 for ( int32_t q = 0; q < 8; q++ )
17920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653192 times.
653192 if(!p_igetw(&temp_combo.attrishorts[q],f))
17921 return qe_invalid;
17922 81649 }
17923
2/2
✓ Branch 0 taken 692596 times.
✓ Branch 1 taken 28011 times.
720607 if(combo_has_flags&CHAS_FLAG)
17924 {
17925
1/2
✓ Branch 0 taken 28011 times.
✗ Branch 1 not taken.
28011 if(!p_igetl(&temp_combo.usrflags,f))
17926 return qe_invalid;
17927
1/2
✓ Branch 0 taken 28011 times.
✗ Branch 1 not taken.
28011 if(!p_igetw(&temp_combo.genflags,f))
17928 return qe_invalid;
17929 28011 }
17930
2/2
✓ Branch 0 taken 703802 times.
✓ Branch 1 taken 16805 times.
720607 if(combo_has_flags&CHAS_TRIG)
17931 {
17932 16805 int numtrigs = s_version < 36 ? 3 : 6;
17933
2/2
✓ Branch 0 taken 99972 times.
✓ Branch 1 taken 16805 times.
116777 for ( int32_t q = 0; q < numtrigs; q++ )
17934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99972 times.
99972 if(!p_igetl(&temp_combo.triggerflags[q],f))
17935 return qe_invalid;
17936
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetl(&temp_combo.triggerlevel,f))
17937 return qe_invalid;
17938
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.triggerbtn,f))
17939 return qe_invalid;
17940
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.triggeritem,f))
17941 return qe_invalid;
17942
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.trigtimer,f))
17943 return qe_invalid;
17944
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.trigsfx,f))
17945 return qe_invalid;
17946
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetl(&temp_combo.trigchange,f))
17947 return qe_invalid;
17948
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetw(&temp_combo.trigprox,f))
17949 return qe_invalid;
17950
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.trigctr,f))
17951 return qe_invalid;
17952
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetl(&temp_combo.trigctramnt,f))
17953 return qe_invalid;
17954
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.triglbeam,f))
17955 return qe_invalid;
17956
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.trigcschange,f))
17957 return qe_invalid;
17958
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetw(&temp_combo.spawnitem,f))
17959 return qe_invalid;
17960
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetw(&temp_combo.spawnenemy,f))
17961 return qe_invalid;
17962
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.exstate,f))
17963 return qe_invalid;
17964
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetl(&temp_combo.spawnip,f))
17965 return qe_invalid;
17966
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.trigcopycat,f))
17967 return qe_invalid;
17968
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.trigcooldown,f))
17969 return qe_invalid;
17970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16805 times.
16805 if(s_version >= 35)
17971 {
17972
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetw(&temp_combo.prompt_cid,f))
17973 return qe_invalid;
17974
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_getc(&temp_combo.prompt_cs,f))
17975 return qe_invalid;
17976
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetw(&temp_combo.prompt_x,f))
17977 return qe_invalid;
17978
1/2
✓ Branch 0 taken 16805 times.
✗ Branch 1 not taken.
16805 if(!p_igetw(&temp_combo.prompt_y,f))
17979 return qe_invalid;
17980 16805 }
17981
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16519 times.
16805 if(s_version >= 36)
17982 {
17983
1/2
✓ Branch 0 taken 16519 times.
✗ Branch 1 not taken.
16519 if(!p_getc(&temp_combo.trig_lstate,f))
17984 return qe_invalid;
17985
1/2
✓ Branch 0 taken 16519 times.
✗ Branch 1 not taken.
16519 if(!p_getc(&temp_combo.trig_gstate,f))
17986 return qe_invalid;
17987
1/2
✓ Branch 0 taken 16519 times.
✗ Branch 1 not taken.
16519 if(!p_igetl(&temp_combo.trig_statetime,f))
17988 return qe_invalid;
17989 16519 }
17990
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16519 times.
16805 if(s_version >= 37)
17991 {
17992
1/2
✓ Branch 0 taken 16519 times.
✗ Branch 1 not taken.
16519 if(!p_igetw(&temp_combo.trig_genscr,f))
17993 return qe_invalid;
17994 16519 }
17995
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 16371 times.
16805 if(s_version >= 38)
17996 {
17997
1/2
✓ Branch 0 taken 16371 times.
✗ Branch 1 not taken.
16371 if(!p_getc(&temp_combo.trig_group,f))
17998 return qe_invalid;
17999
1/2
✓ Branch 0 taken 16371 times.
✗ Branch 1 not taken.
16371 if(!p_igetw(&temp_combo.trig_group_val,f))
18000 return qe_invalid;
18001 16371 }
18002
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 16326 times.
16805 if(s_version >= 45)
18003 {
18004
1/2
✓ Branch 0 taken 16326 times.
✗ Branch 1 not taken.
16326 if(!p_getc(&temp_combo.exdoor_dir,f))
18005 return qe_invalid;
18006
1/2
✓ Branch 0 taken 16326 times.
✗ Branch 1 not taken.
16326 if(!p_getc(&temp_combo.exdoor_ind,f))
18007 return qe_invalid;
18008 16326 }
18009
2/2
✓ Branch 0 taken 12703 times.
✓ Branch 1 taken 4102 times.
16805 if(s_version >= 46)
18010 {
18011
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_getc(&temp_combo.trig_levelitems,f))
18012 return qe_invalid;
18013
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigdmlevel,f))
18014 return qe_invalid;
18015
2/2
✓ Branch 0 taken 12306 times.
✓ Branch 1 taken 4102 times.
16408 for(int q = 0; q < 3; ++q)
18016
1/2
✓ Branch 0 taken 12306 times.
✗ Branch 1 not taken.
12306 if(!p_getc(&temp_combo.trigtint[q],f))
18017 return qe_invalid;
18018
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.triglvlpalette,f))
18019 return qe_invalid;
18020
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigbosspalette,f))
18021 return qe_invalid;
18022
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigquaketime,f))
18023 return qe_invalid;
18024
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigwavytime,f))
18025 return qe_invalid;
18026
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_swjinxtime,f))
18027 return qe_invalid;
18028
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_itmjinxtime,f))
18029 return qe_invalid;
18030
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_stuntime,f))
18031 return qe_invalid;
18032
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_bunnytime,f))
18033 return qe_invalid;
18034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4102 times.
4102 if(!p_getc(&temp_combo.trig_pushtime,f))
18035 return qe_invalid;
18036 4102 }
18037 16805 }
18038
2/2
✓ Branch 0 taken 718488 times.
✓ Branch 1 taken 2119 times.
720607 if(combo_has_flags&CHAS_LIFT)
18039 {
18040
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_igetw(&temp_combo.liftcmb,f))
18041 return qe_invalid;
18042
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftcs,f))
18043 return qe_invalid;
18044
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_igetw(&temp_combo.liftundercmb,f))
18045 return qe_invalid;
18046
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftundercs,f))
18047 return qe_invalid;
18048
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftdmg,f))
18049 return qe_invalid;
18050
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftlvl,f))
18051 return qe_invalid;
18052
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftitm,f))
18053 return qe_invalid;
18054
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftflags,f))
18055 return qe_invalid;
18056
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftgfx,f))
18057 return qe_invalid;
18058
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftsprite,f))
18059 return qe_invalid;
18060
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftsfx,f))
18061 return qe_invalid;
18062
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18063 return qe_invalid;
18064
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.liftbreaksfx,f))
18065 return qe_invalid;
18066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2119 times.
2119 if(s_version >= 34)
18067 {
18068
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.lifthei,f))
18069 return qe_invalid;
18070
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if(!p_getc(&temp_combo.lifttime,f))
18071 return qe_invalid;
18072 2119 }
18073
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2105 times.
2119 if(s_version >= 39)
18074 {
18075
1/2
✓ Branch 0 taken 2105 times.
✗ Branch 1 not taken.
2105 if(!p_getc(&temp_combo.lift_parent_item,f))
18076 return qe_invalid;
18077 2105 }
18078 2119 }
18079
2/2
✓ Branch 0 taken 719305 times.
✓ Branch 1 taken 1302 times.
720607 if(combo_has_flags&CHAS_GENERAL)
18080 {
18081
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.speed_mult,f))
18082 return qe_invalid;
18083
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.speed_div,f))
18084 return qe_invalid;
18085
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_igetzf(&temp_combo.speed_add,f))
18086 return qe_invalid;
18087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1302 times.
1302 if(s_version >= 42)
18088 {
18089
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_appear,f))
18090 return qe_invalid;
18091
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_disappear,f))
18092 return qe_invalid;
18093
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_loop,f))
18094 return qe_invalid;
18095
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_walking,f))
18096 return qe_invalid;
18097
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_standing,f))
18098 return qe_invalid;
18099
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_appear,f))
18100 return qe_invalid;
18101
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_disappear,f))
18102 return qe_invalid;
18103
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_walking,f))
18104 return qe_invalid;
18105
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_standing,f))
18106 return qe_invalid;
18107 1302 }
18108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1302 times.
1302 if(s_version >= 44)
18109 {
18110
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_tap,f))
18111 return qe_invalid;
18112 1302 }
18113 1302 }
18114 720607 }
18115 2380809 update_combo(temp_combo, s_version);
18116 2380809 return 0;
18117 2380809 }
18118 687 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18119 {
18120
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18121
18122 687 word section_version=0;
18123 687 word section_cversion=0;
18124 687 word combos_used=0;
18125 int32_t dummy;
18126 byte padding;
18127 687 newcombo temp_combo;
18128
18129
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if (!should_skip)
18130 {
18131
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 reset_combo_animations();
18132
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 reset_combo_animations2();
18133
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 init_combo_classes();
18134
18135
2/2
✓ Branch 0 taken 44782080 times.
✓ Branch 1 taken 686 times.
44782766 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18136
1/2
✓ Branch 0 taken 44782080 times.
✗ Branch 1 not taken.
44782080 combobuf[q].clear();
18137 686 }
18138
18139
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if(version > 0x192) //Version info
18140 {
18141
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&section_version,f))
18142 {
18143 return qe_invalid;
18144 }
18145 663 FFCore.quest_format[vCombos] = section_version;
18146
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&section_cversion,f))
18147 {
18148 return qe_invalid;
18149 }
18150
18151 //section size
18152
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetl(&dummy,f))
18153 {
18154 return qe_invalid;
18155 }
18156 663 }
18157
18158
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 273 times.
687 if(section_version > 32) //Cleanup time!
18159 {
18160
2/4
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 414 times.
✗ Branch 3 not taken.
414 if(!p_igetw(&combos_used,f))
18161 {
18162 return qe_invalid;
18163 }
18164
2/2
✓ Branch 0 taken 2380809 times.
✓ Branch 1 taken 414 times.
2381223 for(int32_t i=0; i<combos_used; i++)
18165 {
18166
1/2
✓ Branch 0 taken 2380809 times.
✗ Branch 1 not taken.
2380809 auto ret = readcombo_loop(f,section_version,temp_combo);
18167
1/2
✓ Branch 0 taken 2380809 times.
✗ Branch 1 not taken.
2380809 if(ret) return ret;
18168
1/2
✓ Branch 0 taken 2380809 times.
✗ Branch 1 not taken.
2380809 if(i>=start_combo)
18169 {
18170
1/2
✓ Branch 0 taken 2380809 times.
✗ Branch 1 not taken.
2380809 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18171 {
18172 temp_combo.script = 0;
18173 for(int q = 0; q < 8; ++q)
18174 temp_combo.initd[q] = 0;
18175 }
18176
1/2
✓ Branch 0 taken 2380809 times.
✗ Branch 1 not taken.
2380809 combobuf[i] = temp_combo;
18177 2380809 }
18178 2380809 }
18179 414 }
18180 else //Call the old function for all old versions
18181 {
18182
1/2
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
273 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 273 times.
273 if(ret) return ret; //error, end read
18184 }
18185
18186
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if (should_skip)
18187 1 return 0;
18188
18189
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 408 times.
686 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18190 {
18191 408 combobuf[0].walk = 0xF0;
18192 408 combobuf[0].type = 0;
18193 408 combobuf[0].flag = 0;
18194 408 }
18195
18196
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 setup_combo_animations();
18197
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 setup_combo_animations2();
18198 686 return 0;
18199 687 }
18200
18201 604 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18202 {
18203 //these are here to bypass compiler warnings about unused arguments
18204 604 Header=Header;
18205 604 version=version;
18206 604 build=build;
18207
18208 int32_t dummy;
18209 604 word sversion=0, c_sversion;
18210
18211 //section version info
18212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_igetw(&sversion,f))
18213 {
18214 return qe_invalid;
18215 }
18216
18217 604 FFCore.quest_format[vComboAliases] = sversion;
18218
18219 //al_trace("Combo aliases version %d\n", sversion);
18220
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&c_sversion,f))
18221 {
18222 return qe_invalid;
18223 }
18224
18225 //section size
18226
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&dummy,f))
18227 {
18228 return qe_invalid;
18229 }
18230
18231 604 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18232
18233
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 185 times.
604 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18234 {
18235 185 max_num_combo_aliases = MAX250COMBOALIASES;
18236 185 }
18237
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18238 {
18239 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18240 }
18241
18242
2/2
✓ Branch 0 taken 3811328 times.
✓ Branch 1 taken 604 times.
3811932 for(int32_t j=0; j<max_num_combo_aliases; j++)
18243 {
18244 byte width,height,mask,tempcset;
18245 int32_t count;
18246 word tempword;
18247 byte tempbyte;
18248
18249
1/2
✓ Branch 0 taken 3811328 times.
✗ Branch 1 not taken.
3811328 if(!p_igetw(&tempword,f))
18250 {
18251 return qe_invalid;
18252 }
18253
18254 3811328 combo_aliases[j].combo = tempword;
18255
18256
1/2
✓ Branch 0 taken 3811328 times.
✗ Branch 1 not taken.
3811328 if(!p_getc(&tempbyte,f))
18257 {
18258 return qe_invalid;
18259 }
18260
18261 3811328 combo_aliases[j].cset = tempbyte;
18262
18263
1/2
✓ Branch 0 taken 3811328 times.
✗ Branch 1 not taken.
3811328 if(!p_getc(&width,f))
18264 {
18265 return qe_invalid;
18266 }
18267
18268
1/2
✓ Branch 0 taken 3811328 times.
✗ Branch 1 not taken.
3811328 if(!p_getc(&height,f))
18269 {
18270 return qe_invalid;
18271 }
18272
18273
1/2
✓ Branch 0 taken 3811328 times.
✗ Branch 1 not taken.
3811328 if(!p_getc(&mask,f))
18274 {
18275 return qe_invalid;
18276 }
18277
18278 3811328 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18279
18280 3811328 combo_aliases[j].width = width;
18281 3811328 combo_aliases[j].height = height;
18282 3811328 combo_aliases[j].layermask = mask;
18283 3811328 combo_aliases[j].combos.clear();
18284 3811328 combo_aliases[j].csets.clear();
18285
18286
2/2
✓ Branch 0 taken 3919000 times.
✓ Branch 1 taken 3811328 times.
7730328 for(int32_t k=0; k<count; k++)
18287 {
18288
1/2
✓ Branch 0 taken 3919000 times.
✗ Branch 1 not taken.
3919000 if(!p_igetw(&tempword,f))
18289 {
18290 return qe_invalid;
18291 }
18292
18293 3919000 combo_aliases[j].combos[k] = tempword;
18294 3919000 }
18295
18296
2/2
✓ Branch 0 taken 3919000 times.
✓ Branch 1 taken 3811328 times.
7730328 for(int32_t k=0; k<count; k++)
18297 {
18298
1/2
✓ Branch 0 taken 3919000 times.
✗ Branch 1 not taken.
3919000 if(!p_getc(&tempcset,f))
18299 {
18300 return qe_invalid;
18301 }
18302
18303 3919000 combo_aliases[j].csets[k] = tempcset;
18304 3919000 }
18305 3811328 }
18306
18307 //Combo pools!
18308 604 word num_combo_pools = 0;
18309
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 414 times.
604 if(sversion >= 4)
18310 {
18311
1/2
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
414 if(!p_igetw(&num_combo_pools,f))
18312 {
18313 return qe_invalid;
18314 }
18315 414 }
18316
18317
2/2
✓ Branch 0 taken 4947968 times.
✓ Branch 1 taken 604 times.
4948572 for(combo_pool& pool : combo_pools)
18318 {
18319 4947968 pool.clear();
18320 }
18321
18322 604 combo_pool temp_cpool;
18323
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 604 times.
1873 for(word cp = 0; cp < num_combo_pools; ++cp)
18324 {
18325 1269 int32_t num_combos_in_pool = 0;
18326
2/4
✓ Branch 0 taken 1269 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1269 times.
✗ Branch 3 not taken.
1269 if(!p_igetl(&num_combos_in_pool,f))
18327 {
18328 return qe_invalid;
18329 }
18330
2/2
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 96 times.
1269 if(num_combos_in_pool < 1) continue; //nothing to read
18331
18332
1/2
✓ Branch 0 taken 1173 times.
✗ Branch 1 not taken.
1173 temp_cpool.clear();
18333
18334 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18335
2/2
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 5151 times.
6324 for(auto q = 0; q < num_combos_in_pool; ++q)
18336 {
18337
2/4
✓ Branch 0 taken 5151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5151 times.
✗ Branch 3 not taken.
5151 if(!p_igetl(&cp_cid,f))
18338 {
18339 return qe_invalid;
18340 }
18341
2/4
✓ Branch 0 taken 5151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5151 times.
✗ Branch 3 not taken.
5151 if(!p_getc(&cp_cs,f))
18342 {
18343 return qe_invalid;
18344 }
18345
2/4
✓ Branch 0 taken 5151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5151 times.
✗ Branch 3 not taken.
5151 if(!p_igetw(&cp_quant,f))
18346 {
18347 return qe_invalid;
18348 }
18349
1/2
✓ Branch 0 taken 5151 times.
✗ Branch 1 not taken.
5151 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18350 5151 }
18351
18352
1/2
✓ Branch 0 taken 1173 times.
✗ Branch 1 not taken.
1173 combo_pools[cp] = temp_cpool;
18353 1173 }
18354
18355 //Autocombos!
18356 604 word num_combo_autos = 0;
18357
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 203 times.
604 if (sversion >= 5)
18358 {
18359
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if (!p_igetw(&num_combo_autos, f))
18360 {
18361 return qe_invalid;
18362 }
18363 401 }
18364
18365
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 4947968 times.
4948572 for (combo_auto& cauto : combo_autos)
18366 {
18367
1/2
✓ Branch 0 taken 4947968 times.
✗ Branch 1 not taken.
4947968 cauto.clear(true);
18368 }
18369
18370
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 combo_auto temp_cauto;
18371
2/2
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 604 times.
1489 for (word ca = 0; ca < num_combo_autos; ++ca)
18372 {
18373 byte type;
18374 int32_t display_cid, erase_cid;
18375 byte flags, arg;
18376
2/4
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
885 if (!p_getc(&type, f))
18377 {
18378 return qe_invalid;
18379 }
18380
2/4
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
885 if (!p_igetl(&display_cid, f))
18381 {
18382 return qe_invalid;
18383 }
18384
2/4
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
885 if (!p_igetl(&erase_cid, f))
18385 {
18386 return qe_invalid;
18387 }
18388
2/4
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
885 if (!p_getc(&flags, f))
18389 {
18390 return qe_invalid;
18391 }
18392
2/4
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
885 if (!p_getc(&arg, f))
18393 {
18394 return qe_invalid;
18395 }
18396 885 int32_t num_combos_in_cauto = 0;
18397
2/4
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
885 if (!p_igetl(&num_combos_in_cauto, f))
18398 {
18399 return qe_invalid;
18400 }
18401
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 if (num_combos_in_cauto < 1) continue; //nothing to read
18402
18403
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 temp_cauto.clear();
18404
18405
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 temp_cauto.setType(type);
18406
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 temp_cauto.setDisplay(display_cid);
18407
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 temp_cauto.setEraseCombo(erase_cid);
18408
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 temp_cauto.setFlags(flags);
18409
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 temp_cauto.setArg(arg);
18410
18411 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18412
2/2
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 11190 times.
12075 for (auto q = 0; q < num_combos_in_cauto; ++q)
18413 {
18414
2/4
✓ Branch 0 taken 11190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11190 times.
✗ Branch 3 not taken.
11190 if (!p_getc(&ca_ctype, f))
18415 {
18416 return qe_invalid;
18417 }
18418
2/4
✓ Branch 0 taken 11190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11190 times.
✗ Branch 3 not taken.
11190 if (!p_igetl(&ca_cid, f))
18419 {
18420 return qe_invalid;
18421 }
18422
1/2
✓ Branch 0 taken 11190 times.
✗ Branch 1 not taken.
11190 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18423 11190 }
18424
18425
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 combo_autos[ca] = temp_cauto;
18426 885 }
18427
18428 604 return 0;
18429 604 }
18430
18431 687 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18432 {
18433
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18434
18435 //these are here to bypass compiler warnings about unused arguments
18436 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18437 //Capitalized cause it'll save you a headache. -Deedee
18438 687 start_cset=start_cset;
18439 687 max_csets=max_csets;
18440 687 word s_version=0;
18441
18442 miscQdata temp_misc;
18443 687 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18444
18445 byte temp_colordata[48];
18446 char temp_palname[PALNAMESIZE+1];
18447
18448 int32_t dummy;
18449 word palcycles;
18450
18451
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(version > 0x192)
18452 {
18453 //section version info
18454
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
18455 {
18456 return qe_invalid;
18457 }
18458
18459 663 FFCore.quest_format[vCSets] = s_version;
18460
18461 //al_trace("Color data version %d\n", s_version);
18462
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&dummy,f))
18463 {
18464 return qe_invalid;
18465 }
18466
18467 //section size
18468
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
18469 {
18470 return qe_invalid;
18471 }
18472 663 }
18473
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 419 times.
687 if (s_version < 5)
18474 {
18475
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 6 times.
268 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18476
18477 //finally... section data
18478 268 int32_t q = 0;
18479 268 int32_t p = -15;
18480
2/2
✓ Branch 0 taken 64320 times.
✓ Branch 1 taken 268 times.
64588 for(int32_t i=0; i<oldpdTOTAL; ++i)
18481 {
18482 64320 memset(temp_colordata, 0, 48);
18483
18484
1/2
✓ Branch 0 taken 64320 times.
✗ Branch 1 not taken.
64320 if(!pfread(temp_colordata,48,f))
18485 {
18486 return qe_invalid;
18487 }
18488
18489
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 64080 times.
64320 if (should_skip)
18490 240 continue;
18491
18492 64080 memcpy(&colordata[q*48], temp_colordata, 48);
18493
18494 64080 ++q;
18495
8/8
✓ Branch 0 taken 59808 times.
✓ Branch 1 taken 4272 times.
✓ Branch 2 taken 4539 times.
✓ Branch 3 taken 55269 times.
✓ Branch 4 taken 534 times.
✓ Branch 5 taken 4005 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 498 times.
64080 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18496 {
18497
1/2
✓ Branch 0 taken 4503 times.
✗ Branch 1 not taken.
4503 if (s_version < 5) //Bumping up the size of level palettes
18498 {
18499 4503 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18500 4503 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18501 4503 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18502 4503 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18503 4503 q+=4;
18504 4503 }
18505 else
18506 {
18507 for(int m = 0; m < 4; ++m)
18508 {
18509 memset(temp_colordata, 0, 48);
18510 if(!pfread(temp_colordata,48,f))
18511 {
18512 return qe_invalid;
18513 }
18514 memcpy(&colordata[q*48], temp_colordata, 48);
18515 ++q;
18516 }
18517 }
18518 4503 }
18519 64080 ++p;
18520 64080 }
18521
18522
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 250 times.
268 if(RealOldVerion)
18523 {
18524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18525 {
18526 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18527 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18528 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18529 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18530 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18531 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18532 18 }
18533 18 }
18534 else
18535 {
18536 250 memset(temp_colordata, 0, 48);
18537
18538
2/2
✓ Branch 0 taken 783250 times.
✓ Branch 1 taken 250 times.
783500 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18539 {
18540
1/2
✓ Branch 0 taken 783250 times.
✗ Branch 1 not taken.
783250 if(!pfread(temp_colordata,48,f))
18541 {
18542 return qe_invalid;
18543 }
18544
18545
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 780117 times.
783250 if (should_skip)
18546 3133 continue;
18547
18548 780117 memcpy(&colordata[q*48], temp_colordata, 48);
18549
18550 780117 ++q;
18551
7/8
✓ Branch 0 taken 780117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60009 times.
✓ Branch 3 taken 720108 times.
✓ Branch 4 taken 498 times.
✓ Branch 5 taken 59511 times.
✓ Branch 6 taken 370 times.
✓ Branch 7 taken 128 times.
780117 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18552 {
18553
1/2
✓ Branch 0 taken 59881 times.
✗ Branch 1 not taken.
59881 if (s_version < 5) //Bumping up the size of level palettes
18554 {
18555 59881 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18556 59881 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18557 59881 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18558 59881 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18559 59881 q+=4;
18560 59881 }
18561 else
18562 {
18563 for(int m = 0; m < 4; ++m)
18564 {
18565 memset(temp_colordata, 0, 48);
18566 if(!pfread(temp_colordata,48,f))
18567 {
18568 return qe_invalid;
18569 }
18570 memcpy(&colordata[q*48], temp_colordata, 48);
18571 ++q;
18572 }
18573 }
18574 59881 }
18575 780117 ++p;
18576 780117 }
18577
18578
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 185 times.
250 if(s_version < 4)
18579 {
18580
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18581 {
18582 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18583 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18584 64 }
18585 65 }
18586 else
18587 {
18588
2/2
✓ Branch 0 taken 615680 times.
✓ Branch 1 taken 185 times.
615865 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18589 {
18590
1/2
✓ Branch 0 taken 615680 times.
✗ Branch 1 not taken.
615680 if(!pfread(temp_colordata,48,f))
18591 {
18592 return qe_invalid;
18593 }
18594
18595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 615680 times.
615680 if (should_skip)
18596 continue;
18597
18598 615680 memcpy(&colordata[q*48], temp_colordata, 48);
18599 615680 ++q;
18600
5/6
✓ Branch 0 taken 615680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47360 times.
✓ Branch 3 taken 568320 times.
✓ Branch 4 taken 370 times.
✓ Branch 5 taken 46990 times.
615680 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18601 {
18602
1/2
✓ Branch 0 taken 46990 times.
✗ Branch 1 not taken.
46990 if (s_version < 5) //Bumping up the size of level palettes
18603 {
18604 46990 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18605 46990 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18606 46990 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18607 46990 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18608 46990 q+=4;
18609 46990 }
18610 else
18611 {
18612 for(int m = 0; m < 4; ++m)
18613 {
18614 memset(temp_colordata, 0, 48);
18615 if(!pfread(temp_colordata,48,f))
18616 {
18617 return qe_invalid;
18618 }
18619 memcpy(&colordata[q*48], temp_colordata, 48);
18620 ++q;
18621 }
18622 }
18623 46990 }
18624 615680 ++p;
18625 615680 }
18626
18627 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18628 }
18629 }
18630 268 }
18631 else
18632 {
18633
2/2
✓ Branch 0 taken 3665831 times.
✓ Branch 1 taken 419 times.
3666250 for(int32_t i=0; i<pdTOTAL255; ++i)
18634 {
18635 3665831 memset(temp_colordata, 0, 48);
18636
18637
1/2
✓ Branch 0 taken 3665831 times.
✗ Branch 1 not taken.
3665831 if(!pfread(temp_colordata,48,f))
18638 {
18639 return qe_invalid;
18640 }
18641
18642 3665831 memcpy(&colordata[i*48], temp_colordata, 48);
18643 3665831 }
18644 }
18645
18646
5/6
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 663 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
687 if((version < 0x192)||((version == 0x192)&&(build<76)))
18647 {
18648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18649 18 init_palnames();
18650 18 }
18651 else
18652 {
18653 669 int32_t palnamestoread = 0;
18654
18655
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 604 times.
669 if(s_version < 3)
18656 65 palnamestoread = OLDMAXLEVELS;
18657 else
18658 604 palnamestoread = 512;
18659
18660
2/2
✓ Branch 0 taken 325888 times.
✓ Branch 1 taken 669 times.
326557 for(int32_t i=0; i<palnamestoread; ++i)
18661 {
18662
1/2
✓ Branch 0 taken 325888 times.
✗ Branch 1 not taken.
325888 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18663 {
18664 return qe_invalid;
18665 }
18666
18667
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 325632 times.
325888 if (!should_skip)
18668 325632 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18669 325888 }
18670
18671
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 668 times.
669 if (should_skip)
18672 1 return 0;
18673
18674
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 668 times.
17052 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18675 {
18676 16384 memset(palnames[i], 0, PALNAMESIZE);
18677 16384 }
18678 }
18679
18680
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 663 times.
686 if(version > 0x192)
18681 {
18682
2/2
✓ Branch 0 taken 169728 times.
✓ Branch 1 taken 663 times.
170391 for(int32_t i=0; i<256; i++)
18683 {
18684
2/2
✓ Branch 0 taken 509184 times.
✓ Branch 1 taken 169728 times.
678912 for(int32_t j=0; j<3; j++)
18685 {
18686 509184 temp_misc.cycles[i][j].first=0;
18687 509184 temp_misc.cycles[i][j].count=0;
18688 509184 temp_misc.cycles[i][j].speed=0;
18689 509184 }
18690 169728 }
18691
18692
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&palcycles,f))
18693 {
18694 return qe_invalid;
18695 }
18696
18697
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18698 {
18699 return qe_invalid;
18700 }
18701
18702
2/2
✓ Branch 0 taken 15262 times.
✓ Branch 1 taken 663 times.
15925 for(int32_t i=0; i<palcycles; i++)
18703 {
18704
2/2
✓ Branch 0 taken 45786 times.
✓ Branch 1 taken 15262 times.
61048 for(int32_t j=0; j<3; j++)
18705 {
18706
1/2
✓ Branch 0 taken 45786 times.
✗ Branch 1 not taken.
45786 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18707 {
18708 return qe_invalid;
18709 }
18710 45786 }
18711
18712
2/2
✓ Branch 0 taken 45786 times.
✓ Branch 1 taken 15262 times.
61048 for(int32_t j=0; j<3; j++)
18713 {
18714
1/2
✓ Branch 0 taken 45786 times.
✗ Branch 1 not taken.
45786 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18715 {
18716 return qe_invalid;
18717 }
18718 45786 }
18719
18720
2/2
✓ Branch 0 taken 45786 times.
✓ Branch 1 taken 15262 times.
61048 for(int32_t j=0; j<3; j++)
18721 {
18722
1/2
✓ Branch 0 taken 45786 times.
✗ Branch 1 not taken.
45786 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18723 {
18724 return qe_invalid;
18725 }
18726 45786 }
18727 15262 }
18728
18729 663 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18730 663 }
18731
18732 686 return 0;
18733 687 }
18734
18735 687 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18736 {
18737
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18738
18739 687 int32_t tiles_used=0;
18740 687 word section_version = 0;
18741 687 word section_cversion = 0;
18742 687 int32_t section_size= 0;
18743 687 byte *temp_tile = new byte[tilesize(tf32Bit)];
18744
18745 //Tile Expansion
18746 //if ( version >= 0x254 && build >= 41 )
18747
4/4
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 419 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 262 times.
687 if (version < 0x254 && build < 41)
18748 {
18749 //al_trace("Build was < 41 when reading tiles\n");
18750 262 max_tiles = ZC250MAXTILES;
18751 262 }
18752
18753 //al_trace("Max Tiles: %d\n", max_tiles);
18754
18755
2/6
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 687 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
687 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18756 {
18757 if(!init_tiles(true, Header))
18758 {
18759 al_trace("Unable to initialize tiles\n");
18760 }
18761
18762 delete[] temp_tile;
18763 temp_tile=NULL;
18764 return 0;
18765 }
18766 else
18767 {
18768
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 663 times.
687 if(version > 0x192)
18769 {
18770 //section version info
18771
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&section_version,f))
18772 {
18773 delete[] temp_tile;
18774 return qe_invalid;
18775 }
18776
18777 663 FFCore.quest_format[vTiles] = section_version;
18778
18779
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&section_cversion,f))
18780 {
18781 delete[] temp_tile;
18782 return qe_invalid;
18783 }
18784
18785 //section size
18786
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&section_size,f))
18787 {
18788 delete[] temp_tile;
18789 return qe_invalid;
18790 }
18791 663 }
18792
18793 //if ( build < 41 )
18794 //{
18795 // tiles_used = ZC250MAXTILES;
18796 //}
18797
18798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
687 if(version < 0x174)
18799 {
18800 tiles_used=TILES_PER_PAGE*4;
18801 } //no expanded tile space
18802
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 669 times.
687 else if(version < 0x191)
18803 {
18804 18 tiles_used=OLDMAXTILES;
18805 18 }
18806 else
18807 {
18808 //finally... section data
18809
3/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 419 times.
669 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18810 {
18811
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 if(!p_igetl(&tiles_used,f))
18812 {
18813 delete[] temp_tile;
18814 return qe_invalid;
18815 }
18816 419 }
18817 else
18818 {
18819
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(!p_igetw(&tiles_used,f))
18820 {
18821 delete[] temp_tile;
18822 return qe_invalid;
18823 }
18824 }
18825 }
18826
18827
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 tiles_used=zc_min(tiles_used, max_tiles);
18828
18829 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18830 //if ( version < 0x254 && build < 41 )
18831
3/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 419 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
687 if ( version < 0x254 || (version == 0x254 && build < 41) )
18832 //if ( build < 41 )
18833 {
18834
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18835 268 }
18836 else //2.55
18837 {
18838
1/2
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
419 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18839 }
18840
18841 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18842
18843 //al_trace("tiles_used = %d\n", tiles_used);
18844
18845
2/2
✓ Branch 0 taken 28029877 times.
✓ Branch 1 taken 687 times.
28030564 for(int32_t i=0; i<tiles_used; ++i)
18846 {
18847 28029877 byte format=tf4Bit;
18848 28029877 memset(temp_tile, 0, tilesize(tf32Bit));
18849
18850
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 25044421 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28029877 if((version>0x211)||((version==0x211)&&(build>4)))
18851 {
18852
1/2
✓ Branch 0 taken 25044421 times.
✗ Branch 1 not taken.
25044421 if(!p_getc(&format,f))
18853 {
18854 delete[] temp_tile;
18855 return qe_invalid;
18856 }
18857 25044421 }
18858
4/4
✓ Branch 0 taken 18037190 times.
✓ Branch 1 taken 9992687 times.
✓ Branch 2 taken 8239622 times.
✓ Branch 3 taken 9797568 times.
28029877 if(section_version > 2 && !format)
18859 {
18860 9797568 reset_tile(buf,start_tile+i,tf4Bit);
18861 9797568 continue;
18862 }
18863
18864
2/2
✓ Branch 0 taken 17719332 times.
✓ Branch 1 taken 512977 times.
18232309 int size = format == tf4Bit ? 128 : tilesize(format);
18865
1/2
✓ Branch 0 taken 18232309 times.
✗ Branch 1 not taken.
18232309 if(!pfread(temp_tile,size,f))
18866 {
18867 delete[] temp_tile;
18868 return qe_invalid;
18869 }
18870
18871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18232309 times.
18232309 if (should_skip)
18872 continue;
18873
18874 18232309 buf[start_tile+i].format=format;
18875
18876
2/2
✓ Branch 0 taken 18113641 times.
✓ Branch 1 taken 118668 times.
18232309 if(buf[start_tile+i].data)
18877 {
18878 18113641 free(buf[start_tile+i].data);
18879 18113641 buf[start_tile+i].data=NULL;
18880 18113641 }
18881
18882 18232309 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18883
18884
2/2
✓ Branch 0 taken 17719332 times.
✓ Branch 1 taken 512977 times.
18232309 if (format == tf4Bit)
18885 {
18886 byte temp[256];
18887 17719332 byte *si = temp_tile + 128;
18888 17719332 byte *di = temp + 256;
18889
18890
2/2
✓ Branch 0 taken 2268074496 times.
✓ Branch 1 taken 17719332 times.
2285793828 for(int i=127; i>=0; --i)
18891 {
18892 2268074496 (*(--di)) = (*(--si)) >> 4;
18893 2268074496 (*(--di)) = (*si) & 15;
18894 2268074496 }
18895
18896 17719332 memcpy(buf[start_tile+i].data,temp,256);
18897 17719332 }
18898 else
18899 {
18900 512977 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18901 }
18902 18232309 }
18903 }
18904
18905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
687 if (should_skip)
18906 return 0;
18907
18908
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 268 times.
687 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18909 {
18910 //al_trace("Writing blank tile data to new tiles for build < 41\n");
18911
2/2
✓ Branch 0 taken 39926640 times.
✓ Branch 1 taken 268 times.
39926908 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18912 {
18913
18914 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18915 39926640 reset_tile(buf,q,tf4Bit);
18916
18917
18918 /*
18919
18920 byte tempbyte;
18921 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18922 {
18923 tempbyte=buf[ZC250MAXTILES-1].data[i];
18924 buf[q].data[i] = tempbyte;
18925 }
18926 //int32_t temp = tempbyte=buf[130].data[i];
18927 //buf[q].data = buf[ZC250MAXTILES-1].data;
18928 */
18929 //reset_tile(buf,q,tf4Bit);
18930 39926640 }
18931
18932 268 }
18933
18934
4/6
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 268 times.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
687 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
18935 {
18936
2/2
✓ Branch 0 taken 9034269 times.
✓ Branch 1 taken 268 times.
9034537 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18937 {
18938 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
18939 9034269 reset_tile(buf,i,tf4Bit);
18940 9034269 }
18941 268 }
18942 else
18943 {
18944
2/2
✓ Branch 0 taken 71264594 times.
✓ Branch 1 taken 419 times.
71265013 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18945 {
18946 //al_trace("Resetting tiles for build 41+\n");
18947 71264594 reset_tile(buf,i,tf4Bit);
18948 71264594 }
18949 }
18950
18951
5/6
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 663 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
687 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
18952 {
18953
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
18954 {
18955 byte tempbyte;
18956 6 int32_t floattile=wpnsbuf[iwSwim].tile;
18957
18958
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
18959 {
18960 1536 tempbyte=buf[23].data[i];
18961 1536 buf[23].data[i]=buf[24].data[i];
18962 1536 buf[24].data[i]=buf[25].data[i];
18963 1536 buf[25].data[i]=buf[26].data[i];
18964 1536 buf[26].data[i]=tempbyte;
18965 1536 }
18966 //swim tiles are out of order, too, but nobody cared? -Z
18967
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18968 {
18969 1536 tempbyte=buf[floattile+11].data[i];
18970 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
18971 1536 buf[floattile+12].data[i]=tempbyte;
18972 1536 }
18973 6 }
18974 24 }
18975
18976
3/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 604 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
687 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
18977 {
18978
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
18979 {
18980 byte tempbyte;
18981
18982
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18983 {
18984 5632 tempbyte=buf[130].data[i];
18985 5632 buf[130].data[i]=buf[132].data[i];
18986 5632 buf[132].data[i]=tempbyte;
18987
18988 5632 tempbyte=buf[131].data[i];
18989 5632 buf[131].data[i]=buf[133].data[i];
18990 5632 buf[133].data[i]=tempbyte;
18991 5632 }
18992 22 }
18993 83 }
18994
18995 687 al_trace("Registering blank tiles\n");
18996 687 register_blank_tiles();
18997
18998 //memset(temp_tile, 0, tilesize(tf32Bit));
18999
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 delete[] temp_tile;
19000 687 temp_tile=NULL;
19001 687 return 0;
19002 687 }
19003
19004 686 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19005 {
19006
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19007
19008 static byte fake_midi_flags[32];
19009
19010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19011 int32_t dummy;
19012 word dummy2;
19013 // zcmidi_ temp_midi;
19014 int32_t tunes_to_read;
19015 686 int32_t tune_count=0;
19016 686 word section_version=0;
19017 686 zctune temp;
19018
19019
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 663 times.
686 if(Header->zelda_version < 0x193)
19020 {
19021 // mf=Header->data_flags+ZQ_MIDIS2;
19022
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19023 {
19024 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19025 22 }
19026 else
19027 {
19028 1 tunes_to_read=MAXCUSTOMTUNES;
19029 }
19030 23 }
19031 else
19032 {
19033 //section version info
19034
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&section_version,f))
19035 {
19036 return qe_invalid;
19037 }
19038
19039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if (!should_skip)
19040 663 FFCore.quest_format[vMIDIs] = section_version;
19041
19042 //al_trace("Tunes version %d\n", section_version);
19043
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&dummy2,f))
19044 {
19045 return qe_invalid;
19046 }
19047
19048 //section size
19049
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
19050 {
19051 return qe_invalid;
19052 }
19053
19054 //finally... section data
19055
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!pfread(midi_flags,sizeof(midi_flags),f))
19056 {
19057 return qe_invalid;
19058 }
19059
19060 663 tunes_to_read=MAXCUSTOMTUNES;
19061 }
19062
19063
2/2
✓ Branch 0 taken 172872 times.
✓ Branch 1 taken 686 times.
173558 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19064 {
19065
2/2
✓ Branch 0 taken 10210 times.
✓ Branch 1 taken 162662 times.
172872 if(get_bit(mf, i))
19066 {
19067 10210 ++tune_count;
19068 10210 }
19069 172872 }
19070
19071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 if (!should_skip)
19072 686 reset_tunes(tunes); //reset_midis(midis);
19073
19074
2/2
✓ Branch 0 taken 168032 times.
✓ Branch 1 taken 686 times.
168718 for(int32_t i=0; i<tunes_to_read; i++)
19075 {
19076 168032 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19077
19078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 168032 times.
168032 if (!should_skip)
19079 168032 tunes[i].reset(); // reset_midi(midis+i);
19080
19081
2/2
✓ Branch 0 taken 157822 times.
✓ Branch 1 taken 10210 times.
168032 if(get_bit(mf,i))
19082 {
19083
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version < 4)
19084 {
19085
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19086 {
19087 return qe_invalid;
19088 }
19089 2663 }
19090 else
19091 {
19092
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19093 {
19094 return qe_invalid;
19095 }
19096 }
19097
19098
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.start,f))
19099 {
19100 return qe_invalid;
19101 }
19102
19103
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.loop_start,f))
19104 {
19105 return qe_invalid;
19106 }
19107
19108
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.loop_end,f))
19109 {
19110 return qe_invalid;
19111 }
19112
19113
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetw(&temp.loop,f))
19114 {
19115 return qe_invalid;
19116 }
19117
19118
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetw(&temp.volume,f))
19119 {
19120 return qe_invalid;
19121 }
19122
19123
2/2
✓ Branch 0 taken 9961 times.
✓ Branch 1 taken 249 times.
10210 if(Header->zelda_version < 0x193)
19124 {
19125
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19126 {
19127 return qe_invalid;
19128 }
19129 249 }
19130
19131
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version >= 3)
19132 {
19133
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19134 {
19135 return qe_invalid;
19136 }
19137 7547 }
19138
19139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10210 times.
10210 if (!should_skip)
19140 10210 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19141
19142
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19143 {
19144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19145 {
19146 if (read_midi(f)==NULL)
19147 {
19148 return qe_invalid;
19149 }
19150
19151 continue;
19152 }
19153
19154 // old format - a midi is a midi
19155
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19156 {
19157 return qe_invalid;
19158 }
19159
19160 //yes you can do this. Isn't the ? operator awesome? :)
19161 2663 tunes[i].format = MFORMAT_MIDI;
19162 2663 }
19163 else
19164 {
19165 // 'midi' could be midi or nes, gb, ... music
19166
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19167 {
19168 return qe_invalid;
19169 }
19170
19171 7547 zctune *ptr = &tunes[i];
19172
19173
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 switch(temp.format)
19174 {
19175 case MFORMAT_MIDI:
19176
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if((ptr->data=read_midi(f))==NULL)
19177 {
19178 return qe_invalid;
19179 }
19180
19181 7547 break;
19182
19183 default:
19184 return qe_invalid;
19185 break;
19186 }
19187 }
19188 10210 }
19189 168032 }
19190
19191 686 return 0;
19192 686 }
19193
19194 686 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19195 {
19196
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19197
19198 int32_t dummy;
19199 ZCHEATS tempzcheats;
19200 686 char temp_use_cheats=1;
19201 686 memset(&tempzcheats, 0, sizeof(tempzcheats));
19202 686 word s_version = 0;
19203
19204
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 663 times.
686 if(Header->zelda_version > 0x192)
19205 {
19206 //section version info
19207
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&s_version,f))
19208 {
19209 return qe_invalid;
19210 }
19211
19212 663 FFCore.quest_format[vCheats] = s_version;
19213 //al_trace("Cheats version %d\n", dummy);
19214
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetw(&dummy,f))
19215 {
19216 return qe_invalid;
19217 }
19218
19219 //section size
19220
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_igetl(&dummy,f))
19221 {
19222 return qe_invalid;
19223 }
19224
19225 //finally... section data
19226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(!p_getc(&temp_use_cheats,f))
19227 {
19228 return qe_invalid;
19229 }
19230 663 }
19231
19232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 if(Header->data_flags[ZQ_CHEATS2])
19233 {
19234
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 if(!p_igetl(&tempzcheats.flags,f))
19235 {
19236 return qe_invalid;
19237 }
19238
19239
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19240 {
19241 return qe_invalid;
19242 }
19243 686 }
19244
19245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 if (should_skip)
19246 return 0;
19247
19248 686 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19249 686 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19250
19251 686 return 0;
19252 686 }
19253
19254 285 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19255 {
19256
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 262 times.
285 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19257
19258 int32_t dummy;
19259 byte padding, tempbyte;
19260
19261 // Legacy item properties (now integrated into itemdata)
19262 byte sword_hearts[4];
19263 byte beam_hearts[4];
19264 285 byte beam_percent=0;
19265 word beam_power[4];
19266 285 byte hookshot_length=99;
19267 285 byte hookshot_links=100;
19268 285 byte longshot_length=99;
19269 285 byte longshot_links=100;
19270 285 byte moving_fairy_hearts=3;
19271 285 byte moving_fairy_heart_percent=0;
19272 285 byte stationary_fairy_hearts=3;
19273 285 byte stationary_fairy_heart_percent=0;
19274 285 byte moving_fairy_magic=0;
19275 285 byte moving_fairy_magic_percent=0;
19276 285 byte stationary_fairy_magic=0;
19277 285 byte stationary_fairy_magic_percent=0;
19278 285 byte blue_potion_hearts=100;
19279 285 byte blue_potion_heart_percent=1;
19280 285 byte red_potion_hearts=100;
19281 285 byte red_potion_heart_percent=1;
19282 285 byte blue_potion_magic=100;
19283 285 byte blue_potion_magic_percent=1;
19284 285 byte red_potion_magic=100;
19285 285 byte red_potion_magic_percent=1;
19286
19287 285 byte bomb_ratio = 4;
19288
19289 285 subscr_mode = 0;
19290
19291 /* HIGHLY UNORTHODOX UPDATING THING, by L
19292 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19293 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19294 * changing from 13 to 14.
19295 */
19296
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 82 times.
285 if(s_version < 14)
19297 82 fixpolsvoice=true;
19298
19299 /* End highly unorthodox updating thing */
19300
19301
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 112 times.
285 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19302 112 temp_zinit.jump_hero_layer_threshold=0;
19303
19304
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 203 times.
285 if(s_version >= 10)
19305 {
19306 char temp;
19307
19308 //new-style items
19309
2/2
✓ Branch 0 taken 51968 times.
✓ Branch 1 taken 203 times.
52171 for(int32_t j=0; j<256; j++)
19310 {
19311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51968 times.
51968 if(!p_getc(&temp,f))
19312 return qe_invalid;
19313
19314 51968 temp_zinit.set_item(j, temp != 0);
19315 51968 }
19316 203 }
19317
19318
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
285 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19319 {
19320 char temp;
19321
19322 //finally... section data
19323
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
272 if((Header->zelda_version > 0x192)||
19324 //new only
19325
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19326 {
19327 //OLD-style items... sigh
19328
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 60 times.
263 if(s_version < 10)
19329 {
19330
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19331 {
19332 return qe_invalid;
19333 }
19334
19335 60 temp_zinit.set_item(iRaft, temp != 0);
19336
19337
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19338 {
19339 return qe_invalid;
19340 }
19341
19342 60 temp_zinit.set_item(iLadder, temp != 0);
19343
19344
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19345 {
19346 return qe_invalid;
19347 }
19348
19349 60 temp_zinit.set_item(iBook, temp != 0);
19350
19351
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19352 {
19353 return qe_invalid;
19354 }
19355
19356 60 temp_zinit.set_item(iMKey, temp != 0);
19357
19358
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19359 {
19360 return qe_invalid;
19361 }
19362
19363 60 temp_zinit.set_item(iFlippers, temp != 0);
19364
19365
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19366 {
19367 return qe_invalid;
19368 }
19369
19370 60 temp_zinit.set_item(iBoots, temp != 0);
19371 60 }
19372 263 }
19373
19374
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
267 if(s_version < 10)
19375 {
19376 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19377
19378
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19379 {
19380 return qe_invalid;
19381 }
19382
19383
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19384 {
19385 return qe_invalid;
19386 }
19387
19388
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19389 {
19390 return qe_invalid;
19391 }
19392
19393
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19394 {
19395 return qe_invalid;
19396 }
19397
19398
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19399 {
19400 return qe_invalid;
19401 }
19402
19403
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19404 {
19405 return qe_invalid;
19406 }
19407
19408
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19409 {
19410 return qe_invalid;
19411 }
19412
19413 //old only
19414
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19415 {
19416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19418
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19423 4 }
19424
19425 //rings start at level 2... wtf
19426 //account for this -DD
19427 64 tempring <<= 1;
19428 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19429 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19430 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19431 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19432 //bracelet ALSO starts at level 2 :-( -DD
19433 64 tempbracelet<<=1;
19434 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19435 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19436 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19437
19438 //new only
19439
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19440 {
19441
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19442 {
19443
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19444 {
19445 return qe_invalid;
19446 }
19447 32 }
19448 1 }
19449
19450 char tempcandle, tempboomerang, temparrow, tempwhistle;
19451
19452
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19453 {
19454 return qe_invalid;
19455 }
19456
19457
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19458 {
19459 return qe_invalid;
19460 }
19461
19462
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19463 {
19464 return qe_invalid;
19465 }
19466
19467
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19468 {
19469 return qe_invalid;
19470 }
19471
19472 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19473
19474
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19475 {
19476 return qe_invalid;
19477 }
19478
19479 //old only
19480
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19481 {
19482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19486 4 }
19487
19488 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19489 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19490 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19491 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19492 //What about the potion...?
19493
19494 64 }
19495
19496
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 249 times.
267 if(s_version < 29)
19497 {
19498 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19499 //to jab out my eye...
19500
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_getc(&padding,f))
19501 return qe_invalid;
19502 249 temp_zinit.counter[crBOMBS] = padding;
19503
19504
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_getc(&padding,f))
19505 return qe_invalid;
19506 249 temp_zinit.counter[crSBOMBS] = padding;
19507 249 }
19508
19509 //Back to more OLD item code
19510
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
267 if(s_version < 10)
19511 {
19512
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19513 //new only
19514
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19515 {
19516
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19517 {
19518 return qe_invalid;
19519 }
19520
19521 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19522
19523
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19524 {
19525 return qe_invalid;
19526 }
19527
19528 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19529
19530
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19531 {
19532 return qe_invalid;
19533 }
19534
19535 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19536
19537
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19538 {
19539 return qe_invalid;
19540 }
19541
19542 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19543
19544
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19545 {
19546 return qe_invalid;
19547 }
19548
19549 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19550
19551
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19552 {
19553 return qe_invalid;
19554 }
19555
19556 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19557
19558
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19559 {
19560 return qe_invalid;
19561 }
19562
19563 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19564
19565
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19566 {
19567 return qe_invalid;
19568 }
19569
19570 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19571
19572
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19573 {
19574 return qe_invalid;
19575 }
19576
19577 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19578
19579
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19580 {
19581 return qe_invalid;
19582 }
19583
19584
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19585 {
19586
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19587 {
19588
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19589 {
19590 return qe_invalid;
19591 }
19592 32 }
19593 1 }
19594 60 }
19595 64 }
19596
19597 //old only
19598
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
267 if((Header->zelda_version == 0x192)&&(Header->build<174))
19599 {
19600 byte equipment, tmpitm; //bit flags
19601
19602
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19603 {
19604 return qe_invalid;
19605 }
19606
19607 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19608 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19609 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19610 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19611 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19612 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19613
19614
19615
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19616 {
19617 return qe_invalid;
19618 }
19619
19620 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19621 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19622 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19623 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19624 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19625 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19626 4 }
19627
19628
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&tempbyte,f))
19629 return qe_invalid;
19630 267 temp_zinit.mcounter[crLIFE] = tempbyte;
19631
19632
19633
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version < 14)
19634 {
19635 byte temphp;
19636
19637
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19638 {
19639 return qe_invalid;
19640 }
19641
19642 64 temp_zinit.counter[crLIFE]=temphp;
19643
19644
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19645 {
19646 return qe_invalid;
19647 }
19648
19649 64 temp_zinit.cont_heart=temphp;
19650 64 }
19651 else
19652 {
19653
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19654 {
19655 return qe_invalid;
19656 }
19657
19658
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.cont_heart,f))
19659 {
19660 return qe_invalid;
19661 }
19662 }
19663
19664
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.hcp,f))
19665 {
19666 return qe_invalid;
19667 }
19668
19669
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version >= 14)
19670 {
19671
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19672 {
19673 return qe_invalid;
19674 }
19675
19676
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(s_version<16) // July 2007
19677 {
19678 if(get_qr(qr_BRANGPICKUP+1))
19679 temp_zinit.hcp_per_hc = 0xFF;
19680
19681 //Dispose of legacy rule
19682 set_qr(qr_BRANGPICKUP+1, 0);
19683 }
19684 203 }
19685
19686
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 249 times.
267 if(s_version < 29)
19687 {
19688
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_getc(&padding,f))
19689 return qe_invalid;
19690 249 temp_zinit.mcounter[crBOMBS] = padding;
19691 249 }
19692
19693
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19694 {
19695 return qe_invalid;
19696 }
19697
19698
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19699 {
19700 return qe_invalid;
19701 }
19702
19703
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&tempbyte,f))
19704 return qe_invalid;
19705
2/2
✓ Branch 0 taken 2136 times.
✓ Branch 1 taken 267 times.
2403 for(int q = 0; q < 8; ++q)
19706 2136 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19707
19708
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
267 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19709 {
19710
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 203 times.
13195 for(int32_t i=0; i<64; i++)
19711 {
19712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12992 times.
12992 if(!p_getc(&temp_zinit.map[i],f))
19713 {
19714 return qe_invalid;
19715 }
19716 12992 }
19717
19718
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 203 times.
13195 for(int32_t i=0; i<64; i++)
19719 {
19720
1/2
✓ Branch 0 taken 12992 times.
✗ Branch 1 not taken.
12992 if(!p_getc(&temp_zinit.compass[i],f))
19721 {
19722 return qe_invalid;
19723 }
19724 12992 }
19725 203 }
19726 else
19727 {
19728
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19729 {
19730
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.map[i],f))
19731 {
19732 return qe_invalid;
19733 }
19734 2048 }
19735
19736
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19737 {
19738
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.compass[i],f))
19739 {
19740 return qe_invalid;
19741 }
19742 2048 }
19743 }
19744
19745
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
272 if((Header->zelda_version > 0x192)||
19746 //new only
19747
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19748 {
19749
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
263 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19750 {
19751
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 203 times.
13195 for(int32_t i=0; i<64; i++)
19752 {
19753
1/2
✓ Branch 0 taken 12992 times.
✗ Branch 1 not taken.
12992 if(!p_getc(&temp_zinit.boss_key[i],f))
19754 {
19755 return qe_invalid;
19756 }
19757 12992 }
19758 203 }
19759 else
19760 {
19761
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 60 times.
1980 for(int32_t i=0; i<32; i++)
19762 {
19763
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if(!p_getc(&temp_zinit.boss_key[i],f))
19764 {
19765 return qe_invalid;
19766 }
19767 1920 }
19768 }
19769 263 }
19770
19771 byte tmpmisc[16];
19772
2/2
✓ Branch 0 taken 4272 times.
✓ Branch 1 taken 267 times.
4539 for(int32_t i=0; i<16; i++)
19773
1/2
✓ Branch 0 taken 4272 times.
✗ Branch 1 not taken.
4272 if(!p_getc(&tmpmisc[i],f))
19774 return qe_invalid;
19775 267 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19776 267 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19777 267 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19778
19779
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
523 if(s_version < 15) for(int32_t i=0; i<4; i++)
19780
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19781 64 return qe_invalid;
19782
19783
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.last_map,f))
19784 {
19785 return qe_invalid;
19786 }
19787
19788
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.last_screen,f))
19789 {
19790 return qe_invalid;
19791 }
19792
19793
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version < 14)
19794 {
19795 byte tempmp;
19796
19797
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19798 {
19799 return qe_invalid;
19800 }
19801
19802 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19803
19804
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19805 {
19806 return qe_invalid;
19807 }
19808
19809 64 temp_zinit.counter[crMAGIC]=tempmp;
19810 64 }
19811 else
19812 {
19813
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19814 {
19815 return qe_invalid;
19816 }
19817
19818
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19819 {
19820 return qe_invalid;
19821 }
19822 }
19823
19824
19825
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version < 15)
19826 {
19827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
19828 {
19829 64 temp_zinit.mcounter[crMAGIC]*=32;
19830 64 temp_zinit.counter[crMAGIC]*=32;
19831 64 }
19832
19833
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19834 {
19835
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
19836 {
19837 return qe_invalid;
19838 }
19839 256 }
19840
19841
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
19842 {
19843 return qe_invalid;
19844 }
19845 64 }
19846 else
19847 {
19848
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&temp_zinit.bomb_ratio,f))
19849 return qe_invalid;
19850
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(temp_zinit.bomb_ratio < 1)
19851 temp_zinit.bomb_ratio = 1;
19852 203 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19853 }
19854
19855
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
267 if(s_version < 15)
19856 {
19857 byte tempbp;
19858
19859
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19860 {
19861
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19862 {
19863 return qe_invalid;
19864 }
19865
19866 256 beam_power[i]=tempbp;
19867 256 }
19868
19869
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
19870 {
19871 return qe_invalid;
19872 }
19873
19874
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
19875 {
19876 if(!p_getc(&hookshot_length,f))
19877 {
19878 return qe_invalid;
19879 }
19880
19881 if(!p_getc(&longshot_links,f))
19882 {
19883 return qe_invalid;
19884 }
19885
19886 if(!p_getc(&longshot_length,f))
19887 {
19888 return qe_invalid;
19889 }
19890 }
19891 64 }
19892
19893
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.msg_more_x,f))
19894 {
19895 return qe_invalid;
19896 }
19897
19898
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.msg_more_y,f))
19899 {
19900 return qe_invalid;
19901 }
19902
19903
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&subscr_mode,f))
19904 return qe_invalid;
19905
19906 //old only
19907
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
267 if((Header->zelda_version == 0x192)&&(Header->build<174))
19908 {
19909
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
19910 {
19911
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_zinit.boss_key[i],f))
19912 {
19913 return qe_invalid;
19914 }
19915 128 }
19916 4 }
19917
19918
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
267 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19919 {
19920
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 203 times.
263 if(s_version <= 10)
19921 {
19922
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
19923 {
19924 return qe_invalid;
19925 }
19926
19927 60 temp_zinit.start_dmap = (word)tempbyte;
19928 60 }
19929 else
19930 {
19931
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.start_dmap,f))
19932 {
19933 return qe_invalid;
19934 }
19935 }
19936
19937
1/2
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
263 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
19938 {
19939 return qe_invalid;
19940 }
19941 263 }
19942
19943
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 185 times.
267 if(s_version>1 && s_version < 29)
19944 {
19945
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&padding,f))
19946 return qe_invalid;
19947 185 temp_zinit.counter[crARROWS] = padding;
19948
19949
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&padding,f))
19950 return qe_invalid;
19951 185 temp_zinit.mcounter[crARROWS] = padding;
19952 185 }
19953
19954
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version>2)
19955 {
19956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if(s_version <= 10)
19957 {
19958 for(int32_t i=0; i<OLDMAXLEVELS; i++)
19959 {
19960 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19961 {
19962 return qe_invalid;
19963 }
19964 }
19965 }
19966 else
19967 {
19968
2/2
✓ Branch 0 taken 103936 times.
✓ Branch 1 taken 203 times.
104139 for(int32_t i=0; i<MAXLEVELS; i++)
19969 {
19970
1/2
✓ Branch 0 taken 103936 times.
✗ Branch 1 not taken.
103936 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19971 {
19972 return qe_invalid;
19973 }
19974 103936 }
19975 }
19976 203 }
19977
19978
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version>3)
19979 {
19980
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_grid_x,f))
19981 {
19982 return qe_invalid;
19983 }
19984
19985
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_grid_y,f))
19986 {
19987 return qe_invalid;
19988 }
19989
19990
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
19991 {
19992 return qe_invalid;
19993 }
19994
19995
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
19996 {
19997 return qe_invalid;
19998 }
19999
20000
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20001 {
20002 return qe_invalid;
20003 }
20004
20005
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20006 {
20007 return qe_invalid;
20008 }
20009
20010
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20011 {
20012 return qe_invalid;
20013 }
20014
20015
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.ss_flags,f))
20016 {
20017 return qe_invalid;
20018 }
20019
20020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20022 203 }
20023
20024
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
267 if(s_version>4 && s_version<15)
20025 {
20026 if(!p_getc(&moving_fairy_hearts,f))
20027 {
20028 return qe_invalid;
20029 }
20030
20031 if(!p_getc(&moving_fairy_heart_percent,f))
20032 {
20033 return qe_invalid;
20034 }
20035 }
20036
20037
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
267 if(s_version>5 && s_version < 10)
20038 {
20039 if(!p_getc(&temp,f))
20040 {
20041 return qe_invalid;
20042 }
20043
20044 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20045 }
20046
20047
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
267 if(s_version>6 && s_version<15)
20048 {
20049 if(!p_getc(&stationary_fairy_hearts,f))
20050 {
20051 return qe_invalid;
20052 }
20053
20054 if(!p_getc(&stationary_fairy_heart_percent,f))
20055 {
20056 return qe_invalid;
20057 }
20058
20059 if(!p_getc(&moving_fairy_magic,f))
20060 {
20061 return qe_invalid;
20062 }
20063
20064 if(!p_getc(&moving_fairy_magic_percent,f))
20065 {
20066 return qe_invalid;
20067 }
20068
20069 if(!p_getc(&stationary_fairy_magic,f))
20070 {
20071 return qe_invalid;
20072 }
20073
20074 if(!p_getc(&stationary_fairy_magic_percent,f))
20075 {
20076 return qe_invalid;
20077 }
20078
20079 if(!p_getc(&blue_potion_hearts,f))
20080 {
20081 return qe_invalid;
20082 }
20083
20084 if(!p_getc(&blue_potion_heart_percent,f))
20085 {
20086 return qe_invalid;
20087 }
20088
20089 if(!p_getc(&red_potion_hearts,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094 if(!p_getc(&red_potion_heart_percent,f))
20095 {
20096 return qe_invalid;
20097 }
20098
20099 if(!p_getc(&blue_potion_magic,f))
20100 {
20101 return qe_invalid;
20102 }
20103
20104 if(!p_getc(&blue_potion_magic_percent,f))
20105 {
20106 return qe_invalid;
20107 }
20108
20109 if(!p_getc(&red_potion_magic,f))
20110 {
20111 return qe_invalid;
20112 }
20113
20114 if(!p_getc(&red_potion_magic_percent,f))
20115 {
20116 return qe_invalid;
20117 }
20118 }
20119
20120
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version>6)
20121
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&padding,f))
20122 return qe_invalid;
20123
20124
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version>7)
20125 {
20126
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&padding,f))
20127 {
20128 return qe_invalid;
20129 }
20130 203 }
20131
20132
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version>8)
20133 {
20134
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20135 {
20136 return qe_invalid;
20137 }
20138
20139
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20140 {
20141 return qe_invalid;
20142 }
20143 203 }
20144
20145
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 64 times.
267 if(s_version>16)
20146 {
20147
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&tempbyte,f))
20148 {
20149 return qe_invalid;
20150 }
20151 203 temp_zinit.gravity = tempbyte*100;
20152
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&temp_zinit.terminalv,f))
20153 {
20154 return qe_invalid;
20155 }
20156
20157
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&temp_zinit.msg_speed,f))
20158 {
20159 return qe_invalid;
20160 }
20161
20162
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&padding,f))
20163 {
20164 return qe_invalid;
20165 }
20166
20167
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20168 {
20169 return qe_invalid;
20170 }
20171 203 }
20172
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20173 12 temp_zinit.msg_speed = 0;
20174
20175
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 203 times.
267 if(s_version>17)
20176 {
20177
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20178 {
20179 return qe_invalid;
20180 }
20181 203 }
20182
20183 //expaned init data for larger values in 2.55
20184
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 18 times.
267 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20185 {
20186
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20187 {
20188 return qe_invalid;
20189 }
20190
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20191 {
20192 return qe_invalid;
20193 }
20194
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20195 {
20196 return qe_invalid;
20197 }
20198
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20199 {
20200 return qe_invalid;
20201 }
20202
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20203 {
20204 return qe_invalid;
20205 }
20206
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20207 {
20208 return qe_invalid;
20209 }
20210
20211 18 }
20212
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 249 times.
267 if ( s_version >= 20 )
20213 {
20214
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroStep,f))
20215 {
20216 return qe_invalid;
20217 }
20218 18 }
20219 else
20220 {
20221 249 temp_zinit.heroStep = 150; //1.5 pixels per frame
20222 }
20223
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 249 times.
267 if ( s_version >= 21 )
20224 {
20225
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20226 {
20227 return qe_invalid;
20228 }
20229 18 }
20230 else
20231 {
20232 249 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20233 }
20234 //old only
20235
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
267 if((Header->zelda_version == 0x192)&&(Header->build<174))
20236 {
20237 byte items2;
20238
20239
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20240 {
20241 return qe_invalid;
20242 }
20243
20244 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20245 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20246 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20247 4 }
20248
20249
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 5 times.
267 if(Header->zelda_version < 0x193)
20250 {
20251
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20252 {
20253
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20254 {
20255 return qe_invalid;
20256 }
20257 480 }
20258
20259 //new only
20260
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20261 {
20262
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20263 {
20264 return qe_invalid;
20265 }
20266
20267
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20268 {
20269 return qe_invalid;
20270 }
20271 1 }
20272 5 }
20273 267 }
20274
20275
3/6
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
285 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20276 {
20277 //temp_zinit.shield=i_smallshield;
20278 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20279
20280
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20281 82 temp_zinit.set_item(sshieldid, true);
20282 82 }
20283
20284
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20285 {
20286 18 temp_zinit.mcounter[crLIFE]=3;
20287 18 temp_zinit.counter[crLIFE]=3;
20288 18 temp_zinit.cont_heart=3;
20289 18 temp_zinit.mcounter[crBOMBS]=8;
20290 18 }
20291
20292
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20293 {
20294 18 sword_hearts[0]=0;
20295 18 sword_hearts[1]=5;
20296 18 sword_hearts[2]=12;
20297 18 sword_hearts[3]=21;
20298 18 }
20299
20300
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20301 {
20302 18 temp_zinit.last_map=0;
20303 18 temp_zinit.last_screen=0;
20304 18 }
20305
20306
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20307 {
20308 18 temp_zinit.mcounter[crMAGIC]=0;
20309 18 temp_zinit.counter[crMAGIC]=0;
20310 18 temp_zinit.magicdrainrate = 2;
20311 18 }
20312
20313
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20314 {
20315
20316
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20317 {
20318 72 beam_hearts[x]=100;
20319 72 }
20320
20321
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20322 {
20323 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20324 72 set_qr(qr_LENSHINTS+i,0);
20325 72 }
20326
20327
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20328 {
20329 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20330 72 }
20331
20332 18 set_qr(qr_HIDECARRIEDITEMS,0);
20333 18 hookshot_links=100;
20334 18 temp_zinit.msg_more_x=224;
20335 18 temp_zinit.msg_more_y=64;
20336 18 }
20337
20338 // Okay, let's put these legacy values into itemsbuf.
20339
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 82 times.
285 if(s_version < 15)
20340
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20341 {
20342
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20343 {
20344 case iFairyStill:
20345 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20346 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20347 82 itemsbuf[i].misc3 = 0;
20348 82 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20349 82 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20350 82 break;
20351
20352 case iFairyMoving:
20353 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20354 82 itemsbuf[i].misc2 = moving_fairy_magic;
20355 82 itemsbuf[i].misc3 = 50;
20356 82 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20357 82 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20358 82 break;
20359
20360 case iRPotion:
20361 82 itemsbuf[i].misc1 = red_potion_hearts;
20362 82 itemsbuf[i].misc2 = red_potion_magic;
20363 82 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20364 82 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20365 82 break;
20366
20367 case iBPotion:
20368 82 itemsbuf[i].misc1 = blue_potion_hearts;
20369 82 itemsbuf[i].misc2 = blue_potion_magic;
20370 82 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20371 82 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20372 82 break;
20373
20374 case iSword:
20375 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20376 82 itemsbuf[i].misc1 = beam_hearts[0];
20377 82 itemsbuf[i].misc2 = beam_power[0];
20378 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20379 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20380 82 break;
20381
20382 case iWSword:
20383 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20384 82 itemsbuf[i].misc1 = beam_hearts[1];
20385 82 itemsbuf[i].misc2 = beam_power[1];
20386 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20387 82 break;
20388
20389 case iMSword:
20390 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20391 82 itemsbuf[i].misc1 = beam_hearts[2];
20392 82 itemsbuf[i].misc2 = beam_power[2];
20393 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20394 82 break;
20395
20396 case iXSword:
20397 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20398 82 itemsbuf[i].misc1 = beam_hearts[3];
20399 82 itemsbuf[i].misc2 = beam_power[3];
20400 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20401 82 break;
20402
20403 case iHookshot:
20404 82 itemsbuf[i].misc1 = hookshot_length;
20405 82 itemsbuf[i].misc2 = hookshot_links;
20406 82 break;
20407
20408 case iLongshot:
20409 82 itemsbuf[i].misc1 = longshot_length;
20410 82 itemsbuf[i].misc2 = longshot_links;
20411 82 break;
20412 }
20413 21074 }
20414
20415
6/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20416 {
20417 //was new subscreen rule
20418 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20419 22 set_qr(qr_FREEFORM,0);
20420 22 }
20421
20422
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20423 {
20424 23 temp_zinit.start_dmap=0;
20425 23 }
20426
20427
5/6
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 262 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
285 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20428 {
20429 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20430 23 }
20431
20432
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
285 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20433 {
20434 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20435 temp_zinit.mcounter[crMONEY]=999;
20436 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20437 }
20438
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 6 times.
285 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20439 {
20440 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20441 6 temp_zinit.mcounter[crBOMBS] = 8;
20442 6 }
20443 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20444 //time to ensure that we port all new values properly:
20445
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 82 times.
285 if(Header->zelda_version < 0x250)
20446 {
20447
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20448 82 }
20449
20450
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 21)
20451 {
20452
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hp_per_heart,f))
20453 {
20454 return qe_invalid;
20455 }
20456
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magic_per_block,f))
20457 {
20458 return qe_invalid;
20459 }
20460
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20461 {
20462 return qe_invalid;
20463 }
20464
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20465 {
20466 return qe_invalid;
20467 }
20468 18 }
20469 else
20470 {
20471 267 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20472 267 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20473 267 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20474 267 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20475 }
20476
20477
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
285 if(s_version > 22)
20478 {
20479
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.counter[q],f))
20481 return qe_invalid;
20482
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.mcounter[q],f))
20484 return qe_invalid;
20485 18 }
20486
20487
20488
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 23)
20489 {
20490
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_type,f))
20491 {
20492 return qe_invalid;
20493 }
20494
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_arg,f))
20495 {
20496 return qe_invalid;
20497 }
20498
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_percent,f))
20499 {
20500 return qe_invalid;
20501 }
20502
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.def_lightrad,f))
20503 {
20504 return qe_invalid;
20505 }
20506
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.transdark_percent,f))
20507 {
20508 return qe_invalid;
20509 }
20510 18 }
20511 else
20512 {
20513 267 temp_zinit.dither_type = 0;
20514 267 temp_zinit.dither_arg = 0;
20515 267 temp_zinit.dither_percent = 20;
20516 267 temp_zinit.def_lightrad = 24;
20517 267 temp_zinit.transdark_percent = 0;
20518 }
20519
20520
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 24)
20521 {
20522
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.darkcol,f))
20523 {
20524 return qe_invalid;
20525 }
20526 18 }
20527 else
20528 {
20529 267 temp_zinit.darkcol = BLACK;
20530 }
20531
20532
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
285 if(s_version > 25)
20533 {
20534
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.gravity,f))
20535 {
20536 return qe_invalid;
20537 }
20538
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.swimgravity,f))
20539 {
20540 return qe_invalid;
20541 }
20542 18 }
20543
20544
20545
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 26)
20546 {
20547
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20548 {
20549 return qe_invalid;
20550 }
20551
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20552 {
20553 return qe_invalid;
20554 }
20555
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20556 {
20557 return qe_invalid;
20558 }
20559 18 }
20560 else
20561 {
20562 267 temp_zinit.heroSideswimUpStep = 150;
20563 267 temp_zinit.heroSideswimSideStep = 100;
20564 267 temp_zinit.heroSideswimDownStep = 75;
20565 }
20566
20567
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 27)
20568 {
20569
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20570 {
20571 return qe_invalid;
20572 }
20573 18 }
20574 else
20575 {
20576 267 temp_zinit.exitWaterJump = 0;
20577 }
20578
20579
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 29)
20580 {
20581
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20582 {
20583 return qe_invalid;
20584 }
20585 18 }
20586 else
20587 {
20588 267 temp_zinit.bunny_ltm = 0;
20589 }
20590
20591
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 267 times.
285 if(s_version > 30)
20592 {
20593
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.switchhookstyle,f))
20594 {
20595 return qe_invalid;
20596 }
20597 18 }
20598 else
20599 {
20600 267 temp_zinit.switchhookstyle = 1;
20601 }
20602
20603
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 18 times.
285 if(s_version > 31)
20604 {
20605
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magicdrainrate,f))
20606 {
20607 return qe_invalid;
20608 }
20609 18 }
20610
20611 285 temp_zinit.clear_genscript();
20612
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 13 times.
285 if(s_version > 32)
20613 {
20614 13 word numgenscript = 0;
20615
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&numgenscript,f))
20616 return qe_invalid;
20617
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20618 return qe_invalid;
20619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 for(auto q = 1; q < numgenscript; ++q)
20620 {
20621 if(!p_getc(&tempbyte,f))
20622 return qe_invalid;
20623 if(!(tempbyte&2))
20624 continue;
20625 temp_zinit.gen_doscript.set(q, tempbyte&1);
20626 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20627 return qe_invalid;
20628 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20629 return qe_invalid;
20630 for(auto p = 0; p < 8; ++p)
20631 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20632 return qe_invalid;
20633 dword sz;
20634 if(!p_igetl(&sz,f))
20635 return qe_invalid;
20636 temp_zinit.gen_data[q].resize(sz);
20637 std::vector<int32_t> dummy;
20638 if(!p_getlvec(&dummy,f))
20639 return qe_invalid;
20640 temp_zinit.gen_data[q] = dummy;
20641 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20642 return qe_invalid;
20643 }
20644 13 }
20645
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 7 times.
285 if(s_version > 33)
20646 {
20647
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20648 return qe_invalid;
20649
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_div,f))
20650 return qe_invalid;
20651 7 }
20652
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(s_version > 34)
20653 {
20654 uint32_t num_used_mapscr_data;
20655 if(!p_igetl(&num_used_mapscr_data,f))
20656 return qe_invalid;
20657 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20658 {
20659 uint32_t sz;
20660 if(!p_igetl(&sz,f))
20661 return qe_invalid;
20662 temp_zinit.screen_data[q].resize(sz);
20663 if(sz)
20664 {
20665 std::vector<int32_t> dummy;
20666 if(!p_getlvec(&dummy,f))
20667 return qe_invalid;
20668 temp_zinit.screen_data[q] = dummy;
20669 }
20670 }
20671 }
20672
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if (s_version > 35)
20673 if(!p_igetzf(&temp_zinit.shove_offset,f))
20674 return qe_invalid;
20675
20676 285 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20677 285 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20678
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 101 times.
285 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20679 101 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20680
20681 285 return 0;
20682 285 }
20683 686 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20684 {
20685 686 zinitdata temp_zinit = {};
20686
20687
3/4
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
686 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20688
20689 int32_t dummy;
20690 686 word s_version=0, s_cversion=0;
20691 byte padding;
20692
20693
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 if(Header->zelda_version > 0x192)
20694 {
20695
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&s_version,f))
20696 return qe_invalid;
20697 663 FFCore.quest_format[vInitData] = s_version;
20698
20699
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetw(&s_cversion,f))
20700 return qe_invalid;
20701
20702 //section size
20703
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!p_igetl(&dummy,f))
20704 return qe_invalid;
20705 663 }
20706
20707
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 401 times.
686 if(s_version < 37)
20708 {
20709
2/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 285 times.
285 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20710 return ret;
20711 285 }
20712 else
20713 {
20714 401 subscr_mode = ssdtMAX;
20715
2/2
✓ Branch 0 taken 12832 times.
✓ Branch 1 taken 401 times.
13233 for(int q = 0; q < MAXITEMS/8; ++q)
20716
2/4
✓ Branch 0 taken 12832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12832 times.
12832 if(!p_getc(&temp_zinit.items[q], f))
20717 return qe_invalid;
20718
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 25664 times.
26065 for(int q = 0; q < MAXLEVELS/8; ++q)
20719 {
20720
2/4
✓ Branch 0 taken 25664 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25664 times.
✗ Branch 3 not taken.
25664 if(!p_getc(&temp_zinit.map[q], f))
20721 return qe_invalid;
20722
2/4
✓ Branch 0 taken 25664 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25664 times.
25664 if(!p_getc(&temp_zinit.compass[q], f))
20723 return qe_invalid;
20724
2/4
✓ Branch 0 taken 25664 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25664 times.
25664 if(!p_getc(&temp_zinit.boss_key[q], f))
20725 return qe_invalid;
20726
2/4
✓ Branch 0 taken 25664 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25664 times.
✗ Branch 3 not taken.
25664 if(!p_getc(&temp_zinit.mcguffin[q], f))
20727 return qe_invalid;
20728 25664 }
20729
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbvec(&temp_zinit.level_keys, f))
20730 return qe_invalid;
20731 byte num_counters;
20732
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&num_counters,f))
20733 return qe_invalid;
20734
2/2
✓ Branch 0 taken 42907 times.
✓ Branch 1 taken 401 times.
43308 for(int q = 0; q < num_counters; ++q)
20735
2/4
✓ Branch 0 taken 42907 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42907 times.
42907 if(!p_igetw(&temp_zinit.counter[q],f))
20736 return qe_invalid;
20737
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 42907 times.
43308 for(int q = 0; q < num_counters; ++q)
20738
2/4
✓ Branch 0 taken 42907 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42907 times.
42907 if(!p_igetw(&temp_zinit.mcounter[q],f))
20739 return qe_invalid;
20740
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.bomb_ratio,f))
20741 return qe_invalid;
20742
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hcp,f))
20743 return qe_invalid;
20744
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20745 return qe_invalid;
20746
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.cont_heart,f))
20747 return qe_invalid;
20748
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hp_per_heart,f))
20749 return qe_invalid;
20750
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.magic_per_block,f))
20751 return qe_invalid;
20752
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20753 return qe_invalid;
20754
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20755 return qe_invalid;
20756
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.dither_type,f))
20757 return qe_invalid;
20758
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.dither_arg,f))
20759 return qe_invalid;
20760
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.dither_percent,f))
20761 return qe_invalid;
20762
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.def_lightrad,f))
20763 return qe_invalid;
20764
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.transdark_percent,f))
20765 return qe_invalid;
20766
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.darkcol,f))
20767 return qe_invalid;
20768
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20769 return qe_invalid;
20770
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20771 return qe_invalid;
20772
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20773 return qe_invalid;
20774
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20775 return qe_invalid;
20776
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20777 return qe_invalid;
20778
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20779 return qe_invalid;
20780
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20781 return qe_invalid;
20782
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.ss_flags,f))
20783 return qe_invalid;
20784
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbitstr(&temp_zinit.flags,f))
20785 return qe_invalid;
20786
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.last_map,f))
20787 return qe_invalid;
20788
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.last_screen,f))
20789 return qe_invalid;
20790
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.msg_more_x,f))
20791 return qe_invalid;
20792
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.msg_more_y,f))
20793 return qe_invalid;
20794
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20795 return qe_invalid;
20796
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.msg_speed,f))
20797 return qe_invalid;
20798
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.gravity,f))
20799 return qe_invalid;
20800
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.swimgravity,f))
20801 return qe_invalid;
20802
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.terminalv,f))
20803 return qe_invalid;
20804
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20805 return qe_invalid;
20806
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20807 return qe_invalid;
20808
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.hero_swim_div,f))
20809 return qe_invalid;
20810
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20811 return qe_invalid;
20812
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20813 return qe_invalid;
20814
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20815 return qe_invalid;
20816
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20817 return qe_invalid;
20818
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.heroStep,f))
20819 return qe_invalid;
20820
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20821 return qe_invalid;
20822
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20823 return qe_invalid;
20824
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20825 return qe_invalid;
20826
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.start_dmap,f))
20827 return qe_invalid;
20828
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20829 return qe_invalid;
20830
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.switchhookstyle,f))
20831 return qe_invalid;
20832
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getc(&temp_zinit.magicdrainrate,f))
20833 return qe_invalid;
20834
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_igetzf(&temp_zinit.shove_offset,f))
20835 return qe_invalid;
20836
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20837 return qe_invalid;
20838
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20839 return qe_invalid;
20840
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20841 return qe_invalid;
20842
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbmap(&temp_zinit.gen_initd, f))
20843 return qe_invalid;
20844
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20845 return qe_invalid;
20846
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbmap(&temp_zinit.gen_data, f))
20847 return qe_invalid;
20848
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if(!p_getbmap(&temp_zinit.screen_data, f))
20849 return qe_invalid;
20850
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 if (s_version >= 38)
20851 {
20852
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20853 return qe_invalid;
20854
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20855 return qe_invalid;
20856
2/4
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
401 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20857 return qe_invalid;
20858 401 }
20859
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 297 times.
401 if(s_version >= 39)
20860
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetzf(&temp_zinit.air_drag, f))
20861 return qe_invalid;
20862 }
20863
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 if (should_skip)
20864 return 0;
20865
20866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 if(loading_tileset_flags & TILESET_CLEARMAPS)
20867 {
20868 temp_zinit.last_map = 0;
20869 temp_zinit.last_screen = 0;
20870 temp_zinit.screen_data.clear();
20871 }
20872
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 temp_zinit.normalize();
20873
1/2
✓ Branch 0 taken 686 times.
✗ Branch 1 not taken.
686 zinit = temp_zinit;
20874
20875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 if(zinit.heroAnimationStyle==las_zelda3slow)
20876 {
20877 hero_animation_speed=2;
20878 }
20879 else
20880 {
20881 686 hero_animation_speed=1;
20882 }
20883
20884 686 return 0;
20885 686 }
20886
20887 /*
20888 void setupitemdropsets()
20889 {
20890 for(int32_t i=0; i<isMAX; i++)
20891 {
20892 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20893 }
20894 }
20895 */
20896
20897 627 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20898 {
20899
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 23 times.
627 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
20900
20901 627 build=build; // here to prevent compiler warnings
20902 dword dummy_dword;
20903 627 word item_drop_sets_to_read=0;
20904 item_drop_object tempitemdrop;
20905 627 word s_version=0, s_cversion=0;
20906
20907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
627 if (!should_skip)
20908
2/2
✓ Branch 0 taken 160512 times.
✓ Branch 1 taken 627 times.
161139 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20909 {
20910 160512 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20911 161139 }
20912
20913
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 23 times.
627 if(version > 0x192)
20914 {
20915 604 item_drop_sets_to_read=0;
20916
20917 //section version info
20918
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_version,f))
20919 {
20920 return qe_invalid;
20921 }
20922
20923 604 FFCore.quest_format[vItemDropsets] = s_version;
20924
20925 //al_trace("Item drop sets version %d\n", s_version);
20926
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
20927 {
20928 return qe_invalid;
20929 }
20930
20931 //section size
20932
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&dummy_dword,f))
20933 {
20934 return qe_invalid;
20935 }
20936
20937 //finally... section data
20938
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&item_drop_sets_to_read,f))
20939 {
20940 return qe_invalid;
20941 }
20942
20943
2/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604 times.
✗ Branch 3 not taken.
604 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20944 {
20945 return qe_invalid;
20946 }
20947 604 }
20948 else
20949 {
20950 23 init_item_drop_sets();
20951 }
20952
20953
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 604 times.
627 if(s_version>=1)
20954 {
20955
2/2
✓ Branch 0 taken 8687 times.
✓ Branch 1 taken 604 times.
9291 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20956 {
20957
1/2
✓ Branch 0 taken 8687 times.
✗ Branch 1 not taken.
8687 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
20958 {
20959 return qe_invalid;
20960 }
20961
20962
2/2
✓ Branch 0 taken 86870 times.
✓ Branch 1 taken 8687 times.
95557 for(int32_t j=0; j<10; ++j)
20963 {
20964
1/2
✓ Branch 0 taken 86870 times.
✗ Branch 1 not taken.
86870 if(!p_igetw(&tempitemdrop.item[j],f))
20965 {
20966 return qe_invalid;
20967 }
20968 86870 }
20969
20970
2/2
✓ Branch 0 taken 95557 times.
✓ Branch 1 taken 8687 times.
104244 for(int32_t j=0; j<11; ++j)
20971 {
20972
1/2
✓ Branch 0 taken 95557 times.
✗ Branch 1 not taken.
95557 if(!p_igetw(&tempitemdrop.chance[j],f))
20973 {
20974 return qe_invalid;
20975 }
20976 95557 }
20977
20978 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20979 // overrides the quest's set #12.
20980
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8687 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8687 if(s_version<2 && i==12)
20981 continue;
20982
20983 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20984
1/4
✓ Branch 0 taken 8687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8687 if(s_version<2) for(int32_t j=0; j<10; ++j)
20985 {
20986 int32_t it = tempitemdrop.item[j];
20987
20988 if((itemsbuf[it].family == itype_rupee
20989 && ((itemsbuf[it].amount)&0xFFF) == 10)
20990 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20991 {
20992 tempitemdrop.chance[j+1]=0;
20993 }
20994 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20995 {
20996 tempitemdrop.chance[j+1]=0;
20997 }
20998
20999 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21000 if(itemsbuf[it].family == itype_misc)
21001 {
21002 // If a non-gameplay item was selected, then item drop was aborted.
21003 // Reflect this by increasing the 'Nothing' chance accordingly.
21004 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21005 tempitemdrop.chance[j+1]=0;
21006 }
21007 }
21008
21009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8687 times.
8687 if (!should_skip)
21010 8687 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21011 8687 }
21012 604 }
21013
21014 627 return 0;
21015 627 }
21016
21017 604 int32_t readfavorites(PACKFILE *f, int32_t, word)
21018 {
21019
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21020
21021 int32_t temp_num;
21022 dword dummy_dword;
21023 word num_favorite_combos;
21024 word num_favorite_combo_aliases;
21025 604 word s_version=0, s_cversion=0;
21026
21027 //section version info
21028
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_version,f))
21029 {
21030 return qe_invalid;
21031 }
21032
21033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if (!should_skip)
21034 604 FFCore.quest_format[vFavourites] = s_version;
21035
21036
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&s_cversion,f))
21037 {
21038 return qe_invalid;
21039 }
21040
21041 //section size
21042
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetl(&dummy_dword,f))
21043 {
21044 return qe_invalid;
21045 }
21046
21047 604 word per_row = FAVORITECOMBO_PER_ROW;
21048 604 word per_page = FAVORITECOMBO_PER_PAGE;
21049
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 408 times.
604 if(s_version >= 3)
21050
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&per_row,f))
21051 return qe_invalid;
21052
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 401 times.
604 if(s_version >= 4)
21053
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 if(!p_igetw(&per_page,f))
21054 return qe_invalid;
21055 //finally... section data
21056
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 if(!p_igetw(&num_favorite_combos,f))
21057 {
21058 return qe_invalid;
21059 }
21060
21061 //Hack; port old favorite combos
21062
3/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
604 if(s_version < 3 && num_favorite_combos == 100)
21063 196 per_row = 13;
21064
21065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if (!should_skip)
21066
2/2
✓ Branch 0 taken 761040 times.
✓ Branch 1 taken 604 times.
761644 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21067 761644 favorite_combos[q] = -1;
21068 604 byte favtype = 0;
21069
2/2
✓ Branch 0 taken 62726 times.
✓ Branch 1 taken 604 times.
63330 for(int32_t i=0; i<num_favorite_combos; i++)
21070 {
21071
2/2
✓ Branch 0 taken 43119 times.
✓ Branch 1 taken 19607 times.
62726 if (s_version >= 4)
21072 {
21073
1/2
✓ Branch 0 taken 43119 times.
✗ Branch 1 not taken.
43119 if (!p_getc(&favtype, f))
21074 {
21075 return qe_invalid;
21076 }
21077 43119 }
21078 else
21079 19607 favtype = 0;
21080
1/2
✓ Branch 0 taken 62726 times.
✗ Branch 1 not taken.
62726 if(!p_igetl(&temp_num,f))
21081 {
21082 return qe_invalid;
21083 }
21084
21085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62726 times.
62726 if (should_skip)
21086 continue;
21087
21088
2/2
✓ Branch 0 taken 43119 times.
✓ Branch 1 taken 19607 times.
62726 if(per_row == FAVORITECOMBO_PER_ROW)
21089 {
21090 43119 favorite_combos[i] = temp_num;
21091 43119 favorite_combo_modes[i] = favtype;
21092 43119 }
21093 else
21094 {
21095 19607 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21096 19607 favorite_combos[new_i]=temp_num;
21097 19607 favorite_combo_modes[new_i] = favtype;
21098 }
21099 62726 }
21100
21101 // Discard the separate favorite aliases list from previous versions
21102
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 203 times.
604 if(s_version<4)
21103 {
21104
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if (!p_igetw(&num_favorite_combo_aliases, f))
21105 {
21106 return qe_invalid;
21107 }
21108
21109
2/2
✓ Branch 0 taken 19600 times.
✓ Branch 1 taken 203 times.
19803 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21110 {
21111
1/2
✓ Branch 0 taken 19600 times.
✗ Branch 1 not taken.
19600 if (!p_igetl(&temp_num, f))
21112 {
21113 return qe_invalid;
21114 }
21115 19600 }
21116 203 }
21117
21118 604 word max_combo_cols = 0;
21119 604 word max_mappages = 0;
21120
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 408 times.
604 if(s_version >= 2)
21121 {
21122
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&max_combo_cols,f))
21123 return qe_invalid;
21124 408 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21125
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 408 times.
2040 for(int q = 0; q < max_combo_cols; ++q)
21126 {
21127
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(!p_igetl(&tmp,f))
21128 return qe_invalid;
21129
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(!p_igetl(&tmp2,f))
21130 return qe_invalid;
21131
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(!p_igetl(&tmp3,f))
21132 return qe_invalid;
21133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1632 times.
1632 if(q < MAX_COMBO_COLS)
21134 {
21135 1632 First[q] = tmp;
21136 1632 combo_alistpos[q] = tmp2;
21137 1632 combo_pool_listpos[q] = tmp3;
21138 1632 }
21139 1632 }
21140
21141
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&max_mappages,f))
21142 return qe_invalid;
21143
2/2
✓ Branch 0 taken 3672 times.
✓ Branch 1 taken 408 times.
4080 for(int q = 0; q < max_mappages; ++q)
21144 {
21145
1/2
✓ Branch 0 taken 3672 times.
✗ Branch 1 not taken.
3672 if(!p_igetl(&tmp,f))
21146 return qe_invalid;
21147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3672 times.
3672 if(!p_igetl(&tmp2,f))
21148 return qe_invalid;
21149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3672 times.
3672 if(q < MAX_MAPPAGE_BTNS)
21150 {
21151 3672 map_page[q].map = tmp;
21152 3672 map_page[q].screen = tmp2;
21153 3672 }
21154 3672 }
21155 408 }
21156
21157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if (should_skip)
21158 return 0;
21159
21160
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 604 times.
1388 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21161 {
21162 784 First[q] = 0;
21163 784 combo_alistpos[q] = 0;
21164 784 combo_pool_listpos[q] = 0;
21165 784 }
21166
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 604 times.
2368 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21167 {
21168 1764 map_page[q].map = 0;
21169 1764 map_page[q].screen = 0;
21170 1764 }
21171
21172 604 return 0;
21173 604 }
21174
21175 /*
21176 switch (ret) {
21177 case 0:
21178 break;
21179
21180 case qe_invalid:
21181 goto invalid;
21182 break;
21183 default:
21184 pack_fclose(f);
21185 if(!oldquest)
21186 delete_file(tmpfilename);
21187 return ret;
21188 break;
21189 }
21190 */
21191
21192 const char *skip_text[skip_max]=
21193 {
21194 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21195 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21196 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21197 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21198 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21199 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21200 "skip_favorites"
21201 };
21202
21203
21204 void port250QuestRules(){
21205
21206 portCandleRules(); //Candle
21207 portBombRules();
21208
21209 }
21210
21211 void portCandleRules()
21212 {
21213 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21214 //itemdata itemsbuf;
21215 for ( int32_t q = 0; q < MAXITEMS; q++ )
21216 {
21217 if ( itemsbuf[q].family == itype_candle )
21218 {
21219 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21220 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21221 }
21222 }
21223 }
21224
21225 void portBombRules()
21226 {
21227 bool hurtshero = get_qr(qr_OUCHBOMBS);
21228 //itemdata itemsbuf;
21229 for ( int32_t q = 0; q < MAXITEMS; q++ )
21230 {
21231 if ( itemsbuf[q].family == itype_bomb )
21232 {
21233 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21234 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21235 }
21236 }
21237 }
21238
21239 15789 static int section_id_to_enum(int id)
21240 {
21241
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 687 times.
✓ Branch 3 taken 687 times.
✓ Branch 4 taken 687 times.
✓ Branch 5 taken 687 times.
✓ Branch 6 taken 604 times.
✓ Branch 7 taken 687 times.
✓ Branch 8 taken 687 times.
✓ Branch 9 taken 687 times.
✓ Branch 10 taken 687 times.
✓ Branch 11 taken 687 times.
✓ Branch 12 taken 687 times.
✓ Branch 13 taken 604 times.
✓ Branch 14 taken 604 times.
✓ Branch 15 taken 687 times.
✓ Branch 16 taken 687 times.
✓ Branch 17 taken 628 times.
✓ Branch 18 taken 604 times.
✓ Branch 19 taken 604 times.
✓ Branch 20 taken 604 times.
✓ Branch 21 taken 687 times.
✓ Branch 22 taken 687 times.
✓ Branch 23 taken 628 times.
✓ Branch 24 taken 604 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
15789 switch (id)
21242 {
21243 case ID_HEADER: return skip_header;
21244 687 case ID_RULES: return skip_rules;
21245 687 case ID_STRINGS: return skip_strings;
21246 687 case ID_MISC: return skip_misc;
21247 687 case ID_TILES: return skip_tiles;
21248 687 case ID_COMBOS: return skip_combos;
21249 604 case ID_COMBOALIASES: return skip_comboaliases;
21250 687 case ID_CSETS: return skip_csets;
21251 687 case ID_MAPS: return skip_maps;
21252 687 case ID_DMAPS: return skip_dmaps;
21253 687 case ID_DOORS: return skip_doors;
21254 687 case ID_ITEMS: return skip_items;
21255 687 case ID_WEAPONS: return skip_weapons;
21256 604 case ID_COLORS: return skip_colors;
21257 604 case ID_ICONS: return skip_icons;
21258 687 case ID_INITDATA: return skip_initdata;
21259 687 case ID_GUYS: return skip_guys;
21260 628 case ID_HEROSPRITES: return skip_herosprites;
21261 604 case ID_SUBSCREEN: return skip_subscreens;
21262 604 case ID_FFSCRIPT: return skip_ffscript;
21263 604 case ID_SFX: return skip_sfx;
21264 687 case ID_MIDIS: return skip_midis;
21265 687 case ID_CHEATS: return skip_cheats;
21266 628 case ID_ITEMDROPSETS: return skip_itemdropsets;
21267 604 case ID_FAVORITES: return skip_favorites;
21268 case ID_ZINFO: return skip_zinfo;
21269 }
21270
21271 return -1;
21272 15789 }
21273
21274 15381 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21275 {
21276 15381 int section_enum = section_id_to_enum(section_id);
21277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15381 times.
15381 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15381 times.
15381 if (skip)
21279 {
21280 word s_version;
21281 if (!p_igetw(&s_version,f))
21282 {
21283 return qe_invalid;
21284 }
21285
21286 word c_version;
21287 if (!p_igetw(&c_version,f))
21288 {
21289 return qe_invalid;
21290 }
21291
21292 if (section_id == ID_RULES && s_version > 16)
21293 {
21294 dword dummy;
21295 if (!p_igetl(&dummy,f))
21296 {
21297 return qe_invalid;
21298 }
21299 }
21300
21301 if (section_id == ID_FFSCRIPT && s_version >= 18)
21302 {
21303 word dummy;
21304 if (!p_igetw(&dummy,f))
21305 {
21306 return qe_invalid;
21307 }
21308 }
21309
21310 dword section_length;
21311 if (!p_igetl(&section_length,f))
21312 {
21313 return qe_invalid;
21314 }
21315
21316 if (pack_fseek(f, section_length))
21317 {
21318 return qe_invalid;
21319 }
21320
21321 if (!pack_feof(f))
21322 {
21323 if (!p_mgetl(&section_id,f))
21324 {
21325 return qe_invalid;
21326 }
21327 }
21328
21329 return qe_cancel;
21330 }
21331
21332 15381 return qe_OK;
21333 15381 }
21334
21335 //Internal function for loadquest wrapper
21336 687 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21337 {
21338 687 DMapEditorLastMaptileUsed = 0;
21339 687 combosread=false;
21340 687 mapsread=false;
21341 687 fixffcs=false;
21342
21343 687 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21344
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21345 {
21346 set_bit(skip_flags, skip_ffscript, 1);
21347 setZScriptVersion(V_FFSCRIPT);
21348 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21349 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21350 do_clear_scripts = true;
21351 }
21352
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if(loading_tileset_flags & TILESET_CLEARMAPS)
21353 {
21354 set_bit(skip_flags, skip_maps, 1);
21355 }
21356
21357 // show_progress=true;
21358 char tmpfilename[L_tmpnam];
21359 687 temp_name(tmpfilename);
21360 // char percent_done[30];
21361 687 bool catchup=false;
21362 byte tempbyte;
21363 687 word old_map_count=map_count;
21364
21365 687 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21366 687 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21367 687 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21368
21369
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if(get_bit(skip_flags, skip_rules))
21370 {
21371 1 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21372 1 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21373 1 }
21374
21375 687 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21376 687 unpack_qrs();
21377 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21378
21379
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if(get_bit(skip_flags, skip_midis))
21380 {
21381 1 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21382 1 }
21383
21384
21385
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if(do_clear_scripts)
21386 {
21387 686 zScript.clear();
21388 686 globalmap.clear();
21389 686 genericmap.clear();
21390 686 ffcmap.clear();
21391 686 itemmap.clear();
21392 686 npcmap.clear();
21393 686 ewpnmap.clear();
21394 686 lwpnmap.clear();
21395 686 playermap.clear();
21396 686 dmapmap.clear();
21397 686 screenmap.clear();
21398 686 itemspritemap.clear();
21399 686 comboscriptmap.clear();
21400 686 subscreenmap.clear();
21401
21402
2/2
✓ Branch 0 taken 350546 times.
✓ Branch 1 taken 686 times.
351232 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21403 {
21404 350546 ffcmap[i].clear();
21405 350546 }
21406
21407 686 globalmap[0].slotname = "Slot 1:";
21408 686 globalmap[0].scriptname = "~Init";
21409 686 globalmap[0].update();
21410
21411
2/2
✓ Branch 0 taken 4802 times.
✓ Branch 1 taken 686 times.
5488 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21412 {
21413 4802 globalmap[i].clear();
21414 4802 }
21415
21416
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21417 {
21418 174930 itemmap[i].clear();
21419 174930 }
21420
21421 //new script types -- prevent carrying over to a quest that you load after reading them
21422 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21423
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21424 {
21425 174930 npcmap[i].clear();
21426 174930 }
21427
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21428 {
21429 174930 lwpnmap[i].clear();
21430 174930 }
21431
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21432 {
21433 174930 ewpnmap[i].clear();
21434 174930 }
21435
2/2
✓ Branch 0 taken 2744 times.
✓ Branch 1 taken 686 times.
3430 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21436 {
21437 2744 playermap[i].clear();
21438 2744 }
21439
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21440 {
21441 174930 dmapmap[i].clear();
21442 174930 }
21443
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21444 {
21445 174930 screenmap[i].clear();
21446 174930 }
21447
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21448 {
21449 174930 itemspritemap[i].clear();
21450 174930 }
21451
2/2
✓ Branch 0 taken 350546 times.
✓ Branch 1 taken 686 times.
351232 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21452 {
21453 350546 comboscriptmap[i].clear();
21454 350546 }
21455
2/2
✓ Branch 0 taken 350546 times.
✓ Branch 1 taken 686 times.
351232 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21456 {
21457 350546 genericmap[i].clear();
21458 350546 }
21459
2/2
✓ Branch 0 taken 174930 times.
✓ Branch 1 taken 686 times.
175616 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21460 {
21461 174930 subscreenmap[i].clear();
21462 174930 }
21463
21464 686 reset_scripts();
21465 686 }
21466
21467 zquestheader tempheader;
21468 687 memset(&tempheader, 0, sizeof(zquestheader));
21469 687 zinfo tempzi;
21470 687 tempzi.clear();
21471 687 load_tmp_zi = &tempzi;
21472
21473 // oldquest flag is set when an unencrypted qst file is suspected.
21474 687 bool oldquest = false;
21475 687 int32_t open_error=0;
21476 687 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21477
21478
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if (!f)
21479 {
21480 ASSERT(open_error != 0);
21481 return open_error;
21482 }
21483 char zinfofilename[2048];
21484 687 replace_extension(zinfofilename, filename, "zinfo", 2047);
21485 687 int32_t ret=0;
21486
21487 //header
21488 687 box_out("Reading Header...");
21489 687 ret=readheader(f, &tempheader, printmetadata);
21490
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
687 checkstatus(ret);
21491 687 box_out("okay.");
21492 687 box_eol();
21493
21494
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 419 times.
687 if(read_zinfo)
21495 {
21496 419 box_out("Reading ZInfo - ");
21497
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 416 times.
419 box_out(read_ext_zinfo ? "External..." : "Internal...");
21498
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 416 times.
419 if(read_ext_zinfo)
21499 {
21500 3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21501 3 ret=readzinfo(inf, tempzi, tempheader);
21502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(inf) pack_fclose(inf);
21503
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3 checkstatus(ret);
21504 3 }
21505 else
21506 {
21507 416 ret=readzinfo(f, tempzi, tempheader);
21508
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
416 checkstatus(ret);
21509 }
21510 419 box_out("okay.");
21511 419 box_eol();
21512 419 }
21513
21514
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if(tempheader.zelda_version>=0x193)
21515 {
21516 dword section_id;
21517
21518 //section id
21519
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 if(!p_mgetl(&section_id,f))
21520 {
21521 goto invalid;
21522 }
21523
21524 663 std::set<dword> seen_sections;
21525
21526
3/4
✓ Branch 0 taken 16044 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15381 times.
✓ Branch 3 taken 663 times.
16044 while(!pack_feof(f))
21527 {
21528
2/4
✓ Branch 0 taken 15381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15381 times.
✗ Branch 3 not taken.
15381 if (seen_sections.contains(section_id))
21529 goto invalid;
21530
1/2
✓ Branch 0 taken 15381 times.
✗ Branch 1 not taken.
15381 seen_sections.insert(section_id);
21531
21532
2/4
✓ Branch 0 taken 15381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15381 times.
✗ Branch 3 not taken.
15381 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21533 {
21534 if (retval == qe_cancel)
21535 continue;
21536 checkstatus(retval);
21537 }
21538
21539
24/25
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 663 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 663 times.
✓ Branch 4 taken 663 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 663 times.
✓ Branch 7 taken 663 times.
✓ Branch 8 taken 663 times.
✓ Branch 9 taken 663 times.
✓ Branch 10 taken 663 times.
✓ Branch 11 taken 663 times.
✓ Branch 12 taken 604 times.
✓ Branch 13 taken 604 times.
✓ Branch 14 taken 663 times.
✓ Branch 15 taken 663 times.
✓ Branch 16 taken 604 times.
✓ Branch 17 taken 604 times.
✓ Branch 18 taken 604 times.
✓ Branch 19 taken 604 times.
✓ Branch 20 taken 663 times.
✓ Branch 21 taken 663 times.
✓ Branch 22 taken 604 times.
✓ Branch 23 taken 604 times.
✗ Branch 24 not taken.
15381 switch(section_id)
21540 {
21541 case ID_RULES:
21542
21543 //rules
21544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21545 {
21546 box_out("found.");
21547 box_eol();
21548 catchup=false;
21549 }
21550
21551
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Rules...");
21552
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readrules(f, &tempheader);
21553
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21554
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21555
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21556 663 break;
21557
21558 case ID_STRINGS:
21559
21560 //strings
21561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21562 {
21563 box_out("found.");
21564 box_eol();
21565 catchup=false;
21566 }
21567
21568
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Strings...");
21569
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readstrings(f, &tempheader);
21570
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21571
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21572
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21573 663 break;
21574
21575 case ID_MISC:
21576
21577 //misc data
21578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21579 {
21580 box_out("found.");
21581 box_eol();
21582 catchup=false;
21583 }
21584
21585
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Misc. Data...");
21586
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readmisc(f, &tempheader, Misc);
21587
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21588
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21589
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21590 663 break;
21591
21592 case ID_TILES:
21593
21594 //tiles
21595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21596 {
21597 box_out("found.");
21598 box_eol();
21599 catchup=false;
21600 }
21601
21602
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Tiles...");
21603
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21604
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21605
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21606
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21607 663 break;
21608
21609 case ID_COMBOS:
21610
21611 //combos
21612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21613 {
21614 box_out("found.");
21615 box_eol();
21616 catchup=false;
21617 }
21618
21619
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Combos...");
21620
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21621 663 combosread=true;
21622
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21623
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21624
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21625 663 break;
21626
21627 case ID_COMBOALIASES:
21628
21629 //combo aliases
21630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21631 {
21632 box_out("found.");
21633 box_eol();
21634 catchup=false;
21635 }
21636
21637
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Combo Aliases...");
21638
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21639
1/9
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21640
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21641
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21642 604 break;
21643
21644 case ID_CSETS:
21645
21646 //color data
21647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21648 {
21649 box_out("found.");
21650 box_eol();
21651 catchup=false;
21652 }
21653
21654
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Color Data...");
21655
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21656
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21657
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21658
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21659 663 break;
21660
21661 case ID_MAPS:
21662
21663 //maps
21664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21665 {
21666 box_out("found.");
21667 box_eol();
21668 catchup=false;
21669 }
21670
21671
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Maps...");
21672
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readmaps(f, &tempheader);
21673 663 mapsread=true;
21674
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21675
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21676
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21677 663 break;
21678
21679 case ID_DMAPS:
21680
21681 //dmaps
21682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21683 {
21684 box_out("found.");
21685 box_eol();
21686 catchup=false;
21687 }
21688
21689
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading DMaps...");
21690
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21691
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21692
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21693
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21694 663 break;
21695
21696 case ID_DOORS:
21697
21698 //door combo sets
21699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21700 {
21701 box_out("found.");
21702 box_eol();
21703 catchup=false;
21704 }
21705
21706
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Doors...");
21707
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readdoorcombosets(f, &tempheader);
21708
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21709
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21710
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21711 663 break;
21712
21713 case ID_ITEMS:
21714
21715 //items
21716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21717 {
21718 box_out("found.");
21719 box_eol();
21720 catchup=false;
21721 }
21722
21723
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Items...");
21724
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21725
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21726
21727
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21728
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21729 663 break;
21730
21731 case ID_WEAPONS:
21732
21733 //weapons
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21735 {
21736 box_out("found.");
21737 box_eol();
21738 catchup=false;
21739 }
21740
21741
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Weapons...");
21742
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readweapons(f, &tempheader);
21743
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21744
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21745
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21746 663 break;
21747
21748 case ID_COLORS:
21749
21750 //misc. colors
21751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21752 {
21753 box_out("found.");
21754 box_eol();
21755 catchup=false;
21756 }
21757
21758
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Misc. Colors...");
21759
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readmisccolors(f, &tempheader, Misc);
21760
1/9
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21761
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21762
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21763 604 break;
21764
21765 case ID_ICONS:
21766
21767 //game icons
21768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21769 {
21770 box_out("found.");
21771 box_eol();
21772 catchup=false;
21773 }
21774
21775
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Game Icons...");
21776
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readgameicons(f, &tempheader, Misc);
21777
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21778
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21779
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21780 604 break;
21781
21782 case ID_INITDATA:
21783
21784 //initialization data
21785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21786 {
21787 box_out("found.");
21788 box_eol();
21789 catchup=false;
21790 }
21791
21792
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Init. Data...");
21793
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readinitdata(f, &tempheader);
21794
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21795
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21796
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21797
21798
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 if(!get_bit(skip_flags, skip_subscreens))
21799 {
21800
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 579 times.
663 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21801 {
21802
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 setupsubscreens();
21803
21804
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 84 times.
43092 for(int32_t i=0; i<MAXDMAPS; ++i)
21805 {
21806 43008 int32_t type=DMaps[i].type&dmfTYPE;
21807
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 41932 times.
43008 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21808 43008 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21809 43008 }
21810 84 }
21811 663 }
21812
21813
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 if(!get_bit(skip_flags, skip_sfx))
21814 {
21815 663 setupsfx();
21816 663 }
21817
21818
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 663 times.
✗ Branch 3 not taken.
663 if(!get_bit(skip_flags, skip_itemdropsets))
21819 {
21820
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 init_item_drop_sets();
21821 663 }
21822
21823
2/4
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 if(!get_bit(skip_flags, skip_favorites))
21824 {
21825 663 init_favorites();
21826 663 }
21827
21828 663 break;
21829
21830 case ID_GUYS:
21831
21832 //guys
21833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21834 {
21835 box_out("found.");
21836 box_eol();
21837 catchup=false;
21838 }
21839
21840
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Custom Guy Data...");
21841
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readguys(f, &tempheader);
21842
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21843
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21844
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21845 663 break;
21846
21847 case ID_HEROSPRITES:
21848
21849 //player sprites
21850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21851 {
21852 box_out("found.");
21853 box_eol();
21854 catchup=false;
21855 }
21856
21857
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Custom Player Sprite Data...");
21858
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readherosprites(f, &tempheader);
21859
1/9
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21860
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21861
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21862 604 break;
21863
21864 case ID_SUBSCREEN:
21865
21866 //custom subscreens
21867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21868 {
21869 box_out("found.");
21870 box_eol();
21871 catchup=false;
21872 }
21873
21874
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Custom Subscreen Data...");
21875
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readsubscreens(f);
21876
1/9
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21877
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21878
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21879 604 break;
21880
21881 case ID_FFSCRIPT:
21882
21883 //Freeform combo scripts
21884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21885 {
21886 box_out("found.");
21887 box_eol();
21888 catchup=false;
21889 }
21890
21891
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading FF Script Data...");
21892
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readffscript(f, &tempheader);
21893
1/9
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21894
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21895
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21896 604 break;
21897
21898 case ID_SFX:
21899
21900 //SFX data
21901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21902 {
21903 box_out("found.");
21904 box_eol();
21905 catchup=false;
21906 }
21907
21908
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading SFX Data...");
21909
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readsfx(f, &tempheader);
21910
1/9
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21911
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21912
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21913 604 break;
21914
21915 case ID_MIDIS:
21916
21917 //midis
21918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21919 {
21920 box_out("found.");
21921 box_eol();
21922 catchup=false;
21923 }
21924
21925
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Tunes...");
21926
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readtunes(f, &tempheader, tunes);
21927
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21928
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21929
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21930 663 break;
21931
21932 case ID_CHEATS:
21933
21934 //cheat codes
21935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 if(catchup)
21936 {
21937 box_out("found.");
21938 box_eol();
21939 catchup=false;
21940 }
21941
21942
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("Reading Cheat Codes...");
21943
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 ret=readcheatcodes(f, &tempheader);
21944
1/9
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
663 checkstatus(ret);
21945
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_out("okay.");
21946
1/2
✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
663 box_eol();
21947 663 break;
21948
21949 case ID_ITEMDROPSETS:
21950
21951 //item drop sets
21952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21953 {
21954 box_out("found.");
21955 box_eol();
21956 catchup=false;
21957 }
21958
21959
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Item Drop Sets...");
21960
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21961
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21962
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21963
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21964 604 break;
21965
21966 case ID_FAVORITES:
21967
21968 //favorite combos and combo aliases
21969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(catchup)
21970 {
21971 box_out("found.");
21972 box_eol();
21973 catchup=false;
21974 }
21975
21976
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("Reading Favorite Combos...");
21977
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21978
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 604 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
604 checkstatus(ret);
21979
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_out("okay.");
21980
1/2
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
604 box_eol();
21981 604 break;
21982
21983 default:
21984 if(!catchup)
21985 {
21986 box_out("Bad token! Searching...");
21987 box_eol();
21988 }
21989
21990 catchup=true;
21991 break;
21992 }
21993
21994
21995
1/2
✓ Branch 0 taken 15381 times.
✗ Branch 1 not taken.
15381 if(catchup)
21996 {
21997 //section id
21998 section_id=(section_id<<8);
21999
22000 if(!p_getc(&tempbyte,f))
22001 {
22002 goto invalid;
22003 }
22004
22005 section_id+=tempbyte;
22006 }
22007
22008 else
22009 {
22010 //section id
22011
3/4
✓ Branch 0 taken 15381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14718 times.
✓ Branch 3 taken 663 times.
15381 if(!pack_feof(f))
22012 {
22013
2/4
✓ Branch 0 taken 14718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14718 times.
✗ Branch 3 not taken.
14718 if(!p_mgetl(&section_id,f))
22014 {
22015 goto invalid;
22016 }
22017 14718 }
22018 }
22019 }
22020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
663 }
22021 else
22022 {
22023
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22024
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22025
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22026
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22027
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22028
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22029
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22030
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22031
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22032
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22033
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22034
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22035
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22036
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22037
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22038
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22039
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22040
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22041 };
22042
22043 24 legacy_skip_flags = skip_flags;
22044
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22045 {
22046
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22047
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22048
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22049 {
22050 // Nothing to read.
22051
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22052 1 continue;
22053
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22054 1 continue;
22055
22056 // Haven't looked at how to skip these, because we don't need to currently: the only
22057 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22058
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22059 1 continue;
22060
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22061 1 continue;
22062
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22063 1 continue;
22064
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22065 1 continue;
22066
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22067 1 continue;
22068 9 }
22069
22070 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22071 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22072 // read all the sections even if requested to skip some.
22073 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22074 // {
22075 // if (retval == qe_cancel)
22076 // continue;
22077 // checkstatus(retval);
22078 // }
22079
22080
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22081
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22082
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22083
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22084
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22085 }
22086 24 legacy_skip_flags = nullptr;
22087
22088
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22089 {
22090
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22091
22092
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22093 {
22094 11776 int32_t type=DMaps[i].type&dmfTYPE;
22095
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22096 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22097 11776 }
22098 23 }
22099
22100
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22101
22102
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22103 23 setupsfx();
22104
22105
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_favorites))
22106 23 init_favorites();
22107
22108
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22109
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22110
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22111
22112 687 init_spritelists();
22113
22114 // check data
22115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
687 if(f)
22116 {
22117 687 pack_fclose(f);
22118 687 }
22119 687 clear_quest_tmpfile();
22120
22121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
687 if(!oldquest)
22122 {
22123
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if(exists(tmpfilename))
22124 {
22125 delete_file(tmpfilename);
22126 }
22127 687 }
22128
22129
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
687 if(fixffcs && combosread && mapsread)
22130 {
22131 for(int32_t i=0; i<map_count; i++)
22132 {
22133 for(int32_t j=0; j<MAPSCRS; j++)
22134 {
22135 for(int32_t m=0; m<32; m++)
22136 {
22137 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22138 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22139 }
22140 }
22141 }
22142 }
22143
22144
5/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 627 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
687 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22145 {
22146 59 set_qr(qr_CONTFULL_DEP, 0);
22147 59 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22148 59 zinit.cont_heart=100;
22149 59 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22150 59 }
22151
22152 687 box_out("Done.");
22153 687 box_eol();
22154 687 box_end(false);
22155
22156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
687 if(!get_bit(skip_flags, skip_header))
22157 {
22158 687 memcpy(Header, &tempheader, sizeof(tempheader));
22159 687 }
22160
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 686 times.
687 if(!get_bit(skip_flags, skip_zinfo))
22161 {
22162 686 ZI.copyFrom(tempzi);
22163 686 }
22164
22165
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if(get_bit(skip_flags, skip_maps))
22166 {
22167 1 map_count=old_map_count;
22168 1 }
22169
22170
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if(get_bit(skip_flags, skip_rules))
22171 {
22172 1 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22173 1 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22174 1 unpack_qrs();
22175 1 }
22176
22177
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if(get_bit(skip_flags, skip_midis))
22178 {
22179 1 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22180 1 }
22181
22182
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 24 times.
687 if( FFCore.quest_format[vZelda] < 0x210 )
22183 {
22184 24 zprint2("\n[QUEST METADATA]\n");
22185
22186
3/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
24 switch(FFCore.quest_format[vZelda])
22187 {
22188 case 0x193:
22189 {
22190 zprint2("Last saved in version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22191 }
22192 case 0x192:
22193 {
22194 6 zprint2("Last saved in version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22195 }
22196 case 0x190:
22197 {
22198 12 zprint2("Last saved in version: 1.90");
22199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22200 12 else zprint2("\n");
22201 12 break;
22202 }
22203 case 0x188:
22204 {
22205 zprint2("Last saved in version: 1.88");
22206 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22207 else zprint2("\n");
22208 break;
22209 }
22210 case 0x187:
22211 {
22212 zprint2("Last saved in version: 1.87");
22213 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22214 else zprint2("\n");
22215 break;
22216 }
22217 case 0x186:
22218 {
22219 zprint2("Last saved in version: 1.86");
22220 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22221 else zprint2("\n");
22222 break;
22223 }
22224 case 0x185:
22225 {
22226 zprint2("Last saved in version: 1.85");
22227 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22228 else zprint2("\n");
22229 break;
22230 }
22231 case 0x184:
22232 {
22233 6 zprint2("Last saved in version: 1.84");
22234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22235 6 else zprint2("\n");
22236 6 break;
22237 }
22238 case 0x183:
22239 {
22240 zprint2("Last saved in version: 1.83");
22241 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22242 else zprint2("\n");
22243 break;
22244 }
22245 case 0x182:
22246 {
22247 zprint2("Last saved in version: 1.82");
22248 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22249 else zprint2("\n");
22250 break;
22251 }
22252 case 0x181:
22253 {
22254 zprint2("Last saved in version: 1.81");
22255 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22256 else zprint2("\n");
22257 break;
22258 }
22259 case 0x180:
22260 {
22261 zprint2("Last saved in version: 1.80");
22262 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22263 else zprint2("\n");
22264 break;
22265 }
22266 default:
22267 {
22268 zprint2("Last saved in version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22269 }
22270 }
22271 24 }
22272
22273
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if(loading_tileset_flags & TILESET_CLEARMAPS)
22274 {
22275 TheMaps.clear();
22276 TheMaps.resize(MAPSCRS*1);
22277 map_count = 1;
22278 map_autolayers.clear();
22279 map_autolayers.resize(6*1);
22280 for(size_t i = 0; i < MAPSCRS; ++i)
22281 {
22282 TheMaps[i].zero_memory();
22283 }
22284 }
22285
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if(loading_tileset_flags & TILESET_CLEARHEADER)
22286 {
22287 memset(Header->password, 0, sizeof(Header->password));
22288 memset(Header->minver, 0, sizeof(Header->minver));
22289 memset(Header->title, 0, sizeof(Header->title));
22290 memset(Header->author, 0, sizeof(Header->author));
22291 memset(Header->version, 0, sizeof(Header->version));
22292 Header->use_keyfile = 0;
22293 Header->dirty_password = false;
22294 cvs_MD5Context ctx;
22295 cvs_MD5Init(&ctx);
22296 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22297 cvs_MD5Final(Header->pwd_hash, &ctx);
22298 }
22299
22300 687 return qe_OK;
22301
22302 invalid:
22303 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22304 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22305 box_out("error.");
22306 box_eol();
22307 box_end(true);
22308
22309 pack_fclose(f);
22310
22311 if(!oldquest)
22312 {
22313 if(exists(tmpfilename))
22314 {
22315 delete_file(tmpfilename);
22316 }
22317 }
22318
22319 return qe_invalid;
22320
22321 687 }
22322
22323 static bool _is_loading_quest;
22324
22325 bool is_loading_quest()
22326 {
22327 return _is_loading_quest;
22328 }
22329
22330 687 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22331 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22332 bool report, byte qst_num, dword tilesetflags)
22333 {
22334 687 loading_tileset_flags = tilesetflags;
22335 687 const char* basename = get_filename(filename);
22336 687 zapp_reporting_add_breadcrumb("load_quest", basename);
22337 687 zapp_reporting_set_tag("qst.filename", basename);
22338
22339 687 loading_qst_name = filename;
22340 687 loading_qst_num = qst_num;
22341 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22342 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22343
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 if (!is_ci())
22344 loadquest_report = report;
22345
22346 687 _is_loading_quest = true;
22347 687 auto start = std::chrono::steady_clock::now();
22348 687 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22349 687 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22350 687 zprint2("Time to load qst: %d ms\n", load_ms);
22351 687 _is_loading_quest = false;
22352
22353
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 1 times.
687 if(show_progress)
22354 {
22355
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(ret)
22356 {
22357 box_out("-- Error loading quest file! --");
22358 box_end(true);
22359 }
22360 1 else box_end(false);
22361 1 }
22362
22363 687 load_tmp_zi = NULL;
22364 687 loading_qst_name = NULL;
22365 687 loadquest_report = false;
22366 687 loading_qst_num = 0;
22367
22368 687 zapp_reporting_set_tag("qst.author", Header->author);
22369 687 zapp_reporting_set_tag("qst.title", Header->title);
22370 687 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22371
22372 687 return ret;
22373 }
22374